@atlaskit/editor-plugin-annotation 19.1.0 → 19.2.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 +12 -0
- package/dist/cjs/annotationPlugin.js +2 -2
- package/dist/cjs/editor-commands/index.js +22 -14
- package/dist/cjs/editor-commands/transform.js +4 -4
- package/dist/cjs/pm-plugins/annotation-manager-hooks.js +5 -5
- package/dist/cjs/pm-plugins/inline-comment.js +2 -3
- package/dist/cjs/pm-plugins/reducer.js +3 -3
- package/dist/cjs/pm-plugins/utils.js +10 -5
- package/dist/cjs/ui/InlineCommentView.js +3 -3
- package/dist/es2019/annotationPlugin.js +2 -2
- package/dist/es2019/editor-commands/index.js +20 -18
- package/dist/es2019/editor-commands/transform.js +4 -4
- package/dist/es2019/pm-plugins/annotation-manager-hooks.js +5 -5
- package/dist/es2019/pm-plugins/inline-comment.js +3 -4
- package/dist/es2019/pm-plugins/reducer.js +3 -3
- package/dist/es2019/pm-plugins/utils.js +9 -7
- package/dist/es2019/ui/InlineCommentView.js +3 -3
- package/dist/esm/annotationPlugin.js +2 -2
- package/dist/esm/editor-commands/index.js +22 -14
- package/dist/esm/editor-commands/transform.js +4 -4
- package/dist/esm/pm-plugins/annotation-manager-hooks.js +5 -5
- package/dist/esm/pm-plugins/inline-comment.js +3 -4
- package/dist/esm/pm-plugins/reducer.js +3 -3
- package/dist/esm/pm-plugins/utils.js +10 -5
- package/dist/esm/ui/InlineCommentView.js +3 -3
- package/dist/types/editor-commands/index.d.ts +7 -7
- package/dist/types/editor-commands/transform.d.ts +3 -3
- package/dist/types/pm-plugins/annotation-manager-hooks.d.ts +1 -1
- package/dist/types/pm-plugins/types.d.ts +1 -0
- package/dist/types/pm-plugins/utils.d.ts +4 -4
- package/dist/types/types/index.d.ts +9 -0
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 19.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`c408ac489d43a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c408ac489d43a) -
|
|
8
|
+
Add an optional node-aware predicate for block annotation eligibility behind
|
|
9
|
+
`cc_maui_annotations_on_extensions`, while preserving the existing node-name configuration.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 19.1.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -103,8 +103,8 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
103
103
|
var _api$analytics2, _annotationProviders$;
|
|
104
104
|
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$ = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes) !== null && _annotationProviders$ !== void 0 ? _annotationProviders$ : []);
|
|
105
105
|
},
|
|
106
|
-
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),
|
|
107
|
-
showCommentForBlockNode: (0, _editorCommands.showInlineCommentForBlockNode)(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
|
|
106
|
+
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),
|
|
107
|
+
showCommentForBlockNode: (0, _editorCommands.showInlineCommentForBlockNode)(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
|
|
108
108
|
setSelectedAnnotation: _editorCommands.setSelectedAnnotation,
|
|
109
109
|
setPendingSelectedAnnotation: _editorCommands.setPendingSelectedAnnotation
|
|
110
110
|
},
|
|
@@ -88,11 +88,13 @@ var setPendingSelectedAnnotation = exports.setPendingSelectedAnnotation = functi
|
|
|
88
88
|
};
|
|
89
89
|
var removeInlineCommentFromNode = function removeInlineCommentFromNode(id) {
|
|
90
90
|
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
91
|
-
var
|
|
92
|
-
var
|
|
91
|
+
var isBlockNodeSupported = arguments.length > 2 ? arguments[2] : undefined;
|
|
92
|
+
var state = arguments.length > 3 ? arguments[3] : undefined;
|
|
93
|
+
var dispatch = arguments.length > 4 ? arguments[4] : undefined;
|
|
93
94
|
var tr = state.tr,
|
|
94
95
|
selection = state.selection;
|
|
95
|
-
|
|
96
|
+
var selectedNodeIsSupported = selection instanceof _state.NodeSelection && ((0, _utils.isSupportedBlockNode)(selection.node, supportedBlockNodes, isBlockNodeSupported) || selection.node.type === state.schema.nodes.mediaSingle && !!selection.node.firstChild && (0, _utils.isSupportedBlockNode)(selection.node.firstChild, supportedBlockNodes, isBlockNodeSupported));
|
|
97
|
+
if (selectedNodeIsSupported) {
|
|
96
98
|
var $from = selection.$from;
|
|
97
99
|
var currNode = selection.node;
|
|
98
100
|
var from = $from.start();
|
|
@@ -122,10 +124,11 @@ var removeInlineCommentFromNode = function removeInlineCommentFromNode(id) {
|
|
|
122
124
|
};
|
|
123
125
|
var removeInlineCommentNearSelection = exports.removeInlineCommentNearSelection = function removeInlineCommentNearSelection(id) {
|
|
124
126
|
var supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
127
|
+
var isBlockNodeSupported = arguments.length > 2 ? arguments[2] : undefined;
|
|
125
128
|
return function (state, dispatch) {
|
|
126
129
|
var tr = state.tr,
|
|
127
130
|
$from = state.selection.$from;
|
|
128
|
-
if (removeInlineCommentFromNode(id, supportedNodes, state, dispatch)) {
|
|
131
|
+
if (removeInlineCommentFromNode(id, supportedNodes, isBlockNodeSupported, state, dispatch)) {
|
|
129
132
|
return true;
|
|
130
133
|
}
|
|
131
134
|
var annotationMarkType = state.schema.marks.annotation;
|
|
@@ -150,6 +153,7 @@ var removeInlineCommentNearSelection = exports.removeInlineCommentNearSelection
|
|
|
150
153
|
var removeInlineCommentFromDoc = exports.removeInlineCommentFromDoc = function removeInlineCommentFromDoc(editorAnalyticsAPI) {
|
|
151
154
|
return function (id) {
|
|
152
155
|
var supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
156
|
+
var isBlockNodeSupported = arguments.length > 2 ? arguments[2] : undefined;
|
|
153
157
|
return function (state, dispatch) {
|
|
154
158
|
var tr = state.tr;
|
|
155
159
|
state.doc.descendants(function (node, pos) {
|
|
@@ -158,11 +162,11 @@ var removeInlineCommentFromDoc = exports.removeInlineCommentFromDoc = function r
|
|
|
158
162
|
if (node.type.name === 'mediaInline') {
|
|
159
163
|
return false;
|
|
160
164
|
}
|
|
161
|
-
var
|
|
165
|
+
var isSupportedBlock = node.isBlock && (0, _utils.isSupportedBlockNode)(node, supportedNodes, isBlockNodeSupported);
|
|
162
166
|
node.marks.filter(function (mark) {
|
|
163
167
|
return mark.type === state.schema.marks.annotation && mark.attrs.id === id;
|
|
164
168
|
}).forEach(function (mark) {
|
|
165
|
-
if (
|
|
169
|
+
if (isSupportedBlock) {
|
|
166
170
|
tr.removeNodeMark(pos, mark);
|
|
167
171
|
} else {
|
|
168
172
|
tr.removeMark(pos, pos + node.nodeSize, mark);
|
|
@@ -177,10 +181,10 @@ var removeInlineCommentFromDoc = exports.removeInlineCommentFromDoc = function r
|
|
|
177
181
|
};
|
|
178
182
|
};
|
|
179
183
|
};
|
|
180
|
-
var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar) {
|
|
184
|
+
var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isBlockNodeSupported, isOpeningMediaCommentFromToolbar) {
|
|
181
185
|
return function (editorState) {
|
|
182
186
|
// validate selection only when entering draft mode
|
|
183
|
-
if (drafting && (0, _utils.isSelectionValid)(editorState) !== _types2.AnnotationSelectionType.VALID) {
|
|
187
|
+
if (drafting && (0, _utils.isSelectionValid)(editorState, supportedBlockNodes, isBlockNodeSupported) !== _types2.AnnotationSelectionType.VALID) {
|
|
184
188
|
return false;
|
|
185
189
|
}
|
|
186
190
|
return {
|
|
@@ -190,6 +194,7 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
|
|
|
190
194
|
editorState: editorState,
|
|
191
195
|
targetType: targetType,
|
|
192
196
|
supportedBlockNodes: supportedBlockNodes,
|
|
197
|
+
isBlockNodeSupported: isBlockNodeSupported,
|
|
193
198
|
targetNodeId: targetNodeId,
|
|
194
199
|
isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
|
|
195
200
|
}
|
|
@@ -205,11 +210,12 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
|
|
|
205
210
|
*/
|
|
206
211
|
var showInlineCommentForBlockNode = exports.showInlineCommentForBlockNode = function showInlineCommentForBlockNode() {
|
|
207
212
|
var supportedBlockNodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
213
|
+
var isBlockNodeSupported = arguments.length > 1 ? arguments[1] : undefined;
|
|
208
214
|
return function (node, viewMethod, isOpeningMediaCommentFromToolbar) {
|
|
209
215
|
return function (state, dispatch) {
|
|
210
216
|
var pluginState = (0, _utils.getPluginState)(state);
|
|
211
217
|
var annotation = state.schema.marks.annotation;
|
|
212
|
-
if (node && node.isBlock &&
|
|
218
|
+
if (node && node.isBlock && (0, _utils.isSupportedBlockNode)(node, supportedBlockNodes, isBlockNodeSupported)) {
|
|
213
219
|
var unresolvedAnnotationMarks = ((node === null || node === void 0 ? void 0 : node.marks) || []).filter(function (mark) {
|
|
214
220
|
return mark.type === annotation && !(pluginState !== null && pluginState !== void 0 && pluginState.annotations[mark.attrs.id]);
|
|
215
221
|
}).map(function (mark) {
|
|
@@ -242,12 +248,13 @@ var showInlineCommentForBlockNode = exports.showInlineCommentForBlockNode = func
|
|
|
242
248
|
var setInlineCommentDraftState = exports.setInlineCommentDraftState = function setInlineCommentDraftState(editorAnalyticsAPI) {
|
|
243
249
|
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
244
250
|
var api = arguments.length > 2 ? arguments[2] : undefined;
|
|
251
|
+
var isBlockNodeSupported = arguments.length > 3 ? arguments[3] : undefined;
|
|
245
252
|
return function (drafting) {
|
|
246
253
|
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
|
|
247
254
|
var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
|
|
248
255
|
var targetNodeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
249
256
|
var isOpeningMediaCommentFromToolbar = arguments.length > 4 ? arguments[4] : undefined;
|
|
250
|
-
var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar);
|
|
257
|
+
var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isBlockNodeSupported, isOpeningMediaCommentFromToolbar);
|
|
251
258
|
if (Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) {
|
|
252
259
|
return function (state, dispatch) {
|
|
253
260
|
var tr = _transform.default.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod)(state.tr, state);
|
|
@@ -273,7 +280,7 @@ var setInlineCommentDraftState = exports.setInlineCommentDraftState = function s
|
|
|
273
280
|
};
|
|
274
281
|
};
|
|
275
282
|
var addInlineComment = exports.addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
|
|
276
|
-
return function (id, supportedBlockNodes) {
|
|
283
|
+
return function (id, supportedBlockNodes, isBlockNodeSupported) {
|
|
277
284
|
var commandAction = function commandAction(editorState) {
|
|
278
285
|
return {
|
|
279
286
|
type: _types.ACTIONS.ADD_INLINE_COMMENT,
|
|
@@ -292,7 +299,7 @@ var addInlineComment = exports.addInlineComment = function addInlineComment(edit
|
|
|
292
299
|
};
|
|
293
300
|
if (Boolean(editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.toolbar)) {
|
|
294
301
|
return function (state, dispatch) {
|
|
295
|
-
var tr = _transform.default.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes)(state.tr, state);
|
|
302
|
+
var tr = _transform.default.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes, isBlockNodeSupported)(state.tr, state);
|
|
296
303
|
tr.setMeta(_utils.inlineCommentPluginKey, commandAction(state));
|
|
297
304
|
(0, _utils2.resetUserIntent)(editorAPI, tr);
|
|
298
305
|
if (dispatch) {
|
|
@@ -302,7 +309,7 @@ var addInlineComment = exports.addInlineComment = function addInlineComment(edit
|
|
|
302
309
|
return false;
|
|
303
310
|
};
|
|
304
311
|
} else {
|
|
305
|
-
return (0, _pluginFactory.createCommand)(commandAction, _transform.default.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes));
|
|
312
|
+
return (0, _pluginFactory.createCommand)(commandAction, _transform.default.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes, isBlockNodeSupported));
|
|
306
313
|
}
|
|
307
314
|
};
|
|
308
315
|
};
|
|
@@ -340,6 +347,7 @@ var createAnnotation = exports.createAnnotation = function createAnnotation(edit
|
|
|
340
347
|
return function (id) {
|
|
341
348
|
var annotationType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _annotation.AnnotationTypes.INLINE_COMMENT;
|
|
342
349
|
var supportedBlockNodes = arguments.length > 2 ? arguments[2] : undefined;
|
|
350
|
+
var isBlockNodeSupported = arguments.length > 3 ? arguments[3] : undefined;
|
|
343
351
|
return function (state, dispatch) {
|
|
344
352
|
// don't try to add if there are is no temp highlight bookmarked
|
|
345
353
|
var _ref = (0, _utils.getPluginState)(state) || {},
|
|
@@ -348,7 +356,7 @@ var createAnnotation = exports.createAnnotation = function createAnnotation(edit
|
|
|
348
356
|
return false;
|
|
349
357
|
}
|
|
350
358
|
if (annotationType === _annotation.AnnotationTypes.INLINE_COMMENT) {
|
|
351
|
-
return addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes)(state, dispatch);
|
|
359
|
+
return addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes, isBlockNodeSupported)(state, dispatch);
|
|
352
360
|
}
|
|
353
361
|
return false;
|
|
354
362
|
};
|
|
@@ -15,7 +15,7 @@ var _utils2 = require("../pm-plugins/utils");
|
|
|
15
15
|
var isAnnotationStep = function isAnnotationStep(step) {
|
|
16
16
|
return step instanceof _transform.AddMarkStep && step.mark.type.name === 'annotation';
|
|
17
17
|
};
|
|
18
|
-
var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
|
|
18
|
+
var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes, isBlockNodeSupported) {
|
|
19
19
|
return function (transaction, state) {
|
|
20
20
|
var inlineCommentState = (0, _utils2.getPluginState)(state);
|
|
21
21
|
var _ref = inlineCommentState || {},
|
|
@@ -24,7 +24,7 @@ var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
|
|
|
24
24
|
id: id,
|
|
25
25
|
type: _annotation.AnnotationTypes.INLINE_COMMENT
|
|
26
26
|
});
|
|
27
|
-
var _resolveDraftBookmark = (0, _utils2.resolveDraftBookmark)(state, bookmark, supportedBlockNodes),
|
|
27
|
+
var _resolveDraftBookmark = (0, _utils2.resolveDraftBookmark)(state, bookmark, supportedBlockNodes, isBlockNodeSupported),
|
|
28
28
|
from = _resolveDraftBookmark.from,
|
|
29
29
|
to = _resolveDraftBookmark.to,
|
|
30
30
|
head = _resolveDraftBookmark.head,
|
|
@@ -48,10 +48,10 @@ var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
|
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
|
|
51
|
-
return function (id, supportedBlockNodes) {
|
|
51
|
+
return function (id, supportedBlockNodes, isBlockNodeSupported) {
|
|
52
52
|
return function (transaction, state) {
|
|
53
53
|
var _editorAPI$editorView, _pluginState$featureF;
|
|
54
|
-
var tr = addAnnotationMark(id, supportedBlockNodes)(transaction, state);
|
|
54
|
+
var tr = addAnnotationMark(id, supportedBlockNodes, isBlockNodeSupported)(transaction, state);
|
|
55
55
|
editorAPI === null || editorAPI === void 0 || (_editorAPI$editorView = editorAPI.editorViewModeEffects) === null || _editorAPI$editorView === void 0 || _editorAPI$editorView.actions.applyViewModeStepAt(tr);
|
|
56
56
|
|
|
57
57
|
// add insert analytics step to transaction
|
|
@@ -28,7 +28,7 @@ var domRefFromPos = function domRefFromPos(view, position) {
|
|
|
28
28
|
}
|
|
29
29
|
return dom;
|
|
30
30
|
};
|
|
31
|
-
var allowAnnotation = exports.allowAnnotation = function allowAnnotation(editorView,
|
|
31
|
+
var allowAnnotation = exports.allowAnnotation = function allowAnnotation(editorView, options) {
|
|
32
32
|
return function () {
|
|
33
33
|
var _ref = _utils3.inlineCommentPluginKey.getState(editorView.state) || {},
|
|
34
34
|
isDrafting = _ref.isDrafting,
|
|
@@ -42,7 +42,7 @@ var allowAnnotation = exports.allowAnnotation = function allowAnnotation(editorV
|
|
|
42
42
|
if (!!(decoration !== null && decoration !== void 0 && decoration.length)) {
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
|
-
return (0, _utils3.isSelectionValid)(editorView.state) === _types.AnnotationSelectionType.VALID;
|
|
45
|
+
return (0, _utils3.isSelectionValid)(editorView.state, options.provider.supportedBlockNodes, options.provider.isBlockNodeSupported) === _types.AnnotationSelectionType.VALID;
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
48
|
var startDraft = exports.startDraft = function startDraft(editorView, options) {
|
|
@@ -75,7 +75,7 @@ var startDraft = exports.startDraft = function startDraft(editorView, options) {
|
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
(0, _editorCommands.setInlineCommentDraftState)(options.editorAnalyticsAPI,
|
|
78
|
+
(0, _editorCommands.setInlineCommentDraftState)(options.editorAnalyticsAPI, options.provider.supportedBlockNodes, options.api, options.provider.isBlockNodeSupported)(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();
|
|
@@ -159,7 +159,7 @@ var applyDraft = exports.applyDraft = function applyDraft(editorView, options) {
|
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
161
|
var from = decorations[0].from;
|
|
162
|
-
(0, _editorCommands.createAnnotation)(options.editorAnalyticsAPI, options.api)(id, _annotation.AnnotationTypes.INLINE_COMMENT, options.provider.supportedBlockNodes)(editorView.state, editorView.dispatch);
|
|
162
|
+
(0, _editorCommands.createAnnotation)(options.editorAnalyticsAPI, options.api)(id, _annotation.AnnotationTypes.INLINE_COMMENT, options.provider.supportedBlockNodes, options.provider.isBlockNodeSupported)(editorView.state, editorView.dispatch);
|
|
163
163
|
!editorView.hasFocus() && editorView.focus();
|
|
164
164
|
|
|
165
165
|
// Using the original decoration from position we should be able to locate the new target element.
|
|
@@ -343,7 +343,7 @@ var clearAnnotation = exports.clearAnnotation = function clearAnnotation(editorV
|
|
|
343
343
|
reason: ERROR_REASON_ID_INVALID
|
|
344
344
|
};
|
|
345
345
|
}
|
|
346
|
-
(0, _editorCommands.removeInlineCommentFromDoc)(options.editorAnalyticsAPI)(id, options.provider.supportedBlockNodes)(editorView.state, editorView.dispatch);
|
|
346
|
+
(0, _editorCommands.removeInlineCommentFromDoc)(options.editorAnalyticsAPI)(id, options.provider.supportedBlockNodes, options.provider.isBlockNodeSupported)(editorView.state, editorView.dispatch);
|
|
347
347
|
return {
|
|
348
348
|
success: true,
|
|
349
349
|
actionResult: undefined
|
|
@@ -467,13 +467,12 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
467
467
|
// everytime we need to update the decorations. This handler will be called alot. We should be caching
|
|
468
468
|
// the decorations in plugin state and only updating them when required.
|
|
469
469
|
state.doc.descendants(function (node, pos) {
|
|
470
|
-
var _provider$supportedBl;
|
|
471
470
|
// Inline comment on mediaInline is not supported as part of comments on media project
|
|
472
471
|
// Thus, we skip the decoration for mediaInline node
|
|
473
472
|
if (node.type.name === 'mediaInline') {
|
|
474
473
|
return false;
|
|
475
474
|
}
|
|
476
|
-
var
|
|
475
|
+
var isSupportedBlock = node.isBlock && (0, _utils3.isSupportedBlockNode)(node, provider.supportedBlockNodes, provider.isBlockNodeSupported);
|
|
477
476
|
node.marks.filter(function (mark) {
|
|
478
477
|
return mark.type === state.schema.marks.annotation;
|
|
479
478
|
}).forEach(function (mark) {
|
|
@@ -485,7 +484,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
485
484
|
var isHovered = !isInlineCommentViewClosed && !!(hoveredAnnotations !== null && hoveredAnnotations !== void 0 && hoveredAnnotations.some(function (hoveredAnnotation) {
|
|
486
485
|
return hoveredAnnotation.id === mark.attrs.id;
|
|
487
486
|
}));
|
|
488
|
-
if (
|
|
487
|
+
if (isSupportedBlock) {
|
|
489
488
|
focusDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
|
|
490
489
|
class: "".concat((0, _nodeviews.getBlockAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved)
|
|
491
490
|
}, {
|
|
@@ -29,7 +29,7 @@ var _default = exports.default = function _default(pluginState, action) {
|
|
|
29
29
|
mouseData: mouseData
|
|
30
30
|
});
|
|
31
31
|
case _types.ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
|
|
32
|
-
return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.supportedBlockNodes, action.data.targetNodeId, action.data.isOpeningMediaCommentFromToolbar);
|
|
32
|
+
return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.supportedBlockNodes, action.data.isBlockNodeSupported, action.data.targetNodeId, action.data.isOpeningMediaCommentFromToolbar);
|
|
33
33
|
case _types.ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
|
|
34
34
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
35
35
|
dirtyAnnotations: false,
|
|
@@ -91,7 +91,7 @@ var _default = exports.default = function _default(pluginState, action) {
|
|
|
91
91
|
return pluginState;
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, targetNodeId, isOpeningMediaCommentFromToolbar) {
|
|
94
|
+
function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, isBlockNodeSupported, targetNodeId, isOpeningMediaCommentFromToolbar) {
|
|
95
95
|
var draftDecorationSet = pluginState.draftDecorationSet;
|
|
96
96
|
if (!draftDecorationSet || !drafting) {
|
|
97
97
|
draftDecorationSet = _view.DecorationSet.empty;
|
|
@@ -104,7 +104,7 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, suppor
|
|
|
104
104
|
newState.bookmark = undefined;
|
|
105
105
|
if (drafting && editorState) {
|
|
106
106
|
newState.bookmark = editorState.selection.getBookmark();
|
|
107
|
-
var _resolveDraftBookmark = (0, _utils.resolveDraftBookmark)(editorState, newState.bookmark, supportedBlockNodes),
|
|
107
|
+
var _resolveDraftBookmark = (0, _utils.resolveDraftBookmark)(editorState, newState.bookmark, supportedBlockNodes, isBlockNodeSupported),
|
|
108
108
|
from = _resolveDraftBookmark.from,
|
|
109
109
|
to = _resolveDraftBookmark.to;
|
|
110
110
|
var draftDecoration = (0, _utils.addDraftDecoration)(from, to, targetType);
|
|
@@ -202,6 +202,7 @@ var findAnnotationsInSelection = exports.findAnnotationsInSelection = function f
|
|
|
202
202
|
};
|
|
203
203
|
var resolveDraftBookmark = exports.resolveDraftBookmark = function resolveDraftBookmark(editorState, bookmark) {
|
|
204
204
|
var supportedBlockNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
205
|
+
var isBlockNodeSupported = arguments.length > 3 ? arguments[3] : undefined;
|
|
205
206
|
var doc = editorState.doc;
|
|
206
207
|
var resolvedBookmark = bookmark ? bookmark.resolve(doc) : editorState.selection;
|
|
207
208
|
var from = resolvedBookmark.from,
|
|
@@ -223,7 +224,8 @@ var resolveDraftBookmark = exports.resolveDraftBookmark = function resolveDraftB
|
|
|
223
224
|
return false;
|
|
224
225
|
}
|
|
225
226
|
var nodeEndsAt = pos + node.nodeSize;
|
|
226
|
-
|
|
227
|
+
var isLegacyMediaSingleWrapper = node.type.name === 'mediaSingle' && supportedBlockNodes.includes('media') && !supportedBlockNodes.includes('mediaSingle');
|
|
228
|
+
if (isSupportedBlockNode(node, supportedBlockNodes, isBlockNodeSupported) && !isLegacyMediaSingleWrapper) {
|
|
227
229
|
draftBookmark = {
|
|
228
230
|
from: pos,
|
|
229
231
|
to: nodeEndsAt,
|
|
@@ -300,14 +302,16 @@ var getDraftCommandAnalyticsPayload = exports.getDraftCommandAnalyticsPayload =
|
|
|
300
302
|
};
|
|
301
303
|
var isSelectionValid = exports.isSelectionValid = function isSelectionValid(state) {
|
|
302
304
|
var _currentMediaNodeWith;
|
|
303
|
-
var
|
|
305
|
+
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
306
|
+
var isBlockNodeSupported = arguments.length > 2 ? arguments[2] : undefined;
|
|
304
307
|
var selection = state.selection;
|
|
305
308
|
var _ref3 = getPluginState(state) || {},
|
|
306
309
|
disallowOnWhitespace = _ref3.disallowOnWhitespace;
|
|
307
310
|
var allowedInlineNodes = ['emoji', 'status', 'date', 'mention', 'inlineCard'];
|
|
308
311
|
var isSelectionEmpty = selection.empty;
|
|
309
312
|
var isTextOrAllSelection = selection instanceof _state.TextSelection || selection instanceof _state.AllSelection;
|
|
310
|
-
var
|
|
313
|
+
var isSupportedBlockNodeSelection = selection instanceof _state.NodeSelection && isSupportedBlockNode(selection.node, supportedBlockNodes, isBlockNodeSupported);
|
|
314
|
+
var isValidNodeSelection = selection instanceof _state.NodeSelection && (allowedInlineNodes.includes(selection.node.type.name) || isSupportedBlockNodeSelection);
|
|
311
315
|
var isValidSelection = isTextOrAllSelection || isValidNodeSelection;
|
|
312
316
|
|
|
313
317
|
// Allow media so that it can enter draft mode
|
|
@@ -317,7 +321,7 @@ var isSelectionValid = exports.isSelectionValid = function isSelectionValid(stat
|
|
|
317
321
|
if (isSelectionEmpty || !isValidSelection) {
|
|
318
322
|
return _types.AnnotationSelectionType.INVALID;
|
|
319
323
|
}
|
|
320
|
-
var containsInvalidNodes = hasInvalidNodes(state);
|
|
324
|
+
var containsInvalidNodes = !isSupportedBlockNodeSelection && hasInvalidNodes(state);
|
|
321
325
|
|
|
322
326
|
// A selection that only covers 1 pos, and is an invalid node
|
|
323
327
|
// e.g. a text selection over a mention
|
|
@@ -346,7 +350,8 @@ var hasInvalidNodes = exports.hasInvalidNodes = function hasInvalidNodes(state)
|
|
|
346
350
|
};
|
|
347
351
|
var isSupportedBlockNode = exports.isSupportedBlockNode = function isSupportedBlockNode(node) {
|
|
348
352
|
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
349
|
-
|
|
353
|
+
var isBlockNodeSupported = arguments.length > 2 ? arguments[2] : undefined;
|
|
354
|
+
return supportedBlockNodes.indexOf(node.type.name) >= 0 || node.type.name === 'mediaSingle' && supportedBlockNodes.indexOf('media') >= 0 || (0, _fg.fg)('cc_maui_annotations_on_extensions') && (isBlockNodeSupported === null || isBlockNodeSupported === void 0 ? void 0 : isBlockNodeSupported(node)) === true;
|
|
350
355
|
};
|
|
351
356
|
|
|
352
357
|
/**
|
|
@@ -122,7 +122,7 @@ function InlineCommentView(_ref) {
|
|
|
122
122
|
,
|
|
123
123
|
onCreate: function onCreate(id) {
|
|
124
124
|
if (!isAnnotationManagerEnabled) {
|
|
125
|
-
var createAnnotationResult = (0, _editorCommands.createAnnotation)(editorAnalyticsAPI, editorAPI)(id, _annotation.AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
|
|
125
|
+
var createAnnotationResult = (0, _editorCommands.createAnnotation)(editorAnalyticsAPI, editorAPI)(id, _annotation.AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes, inlineCommentProvider.isBlockNodeSupported)(editorView.state, editorView.dispatch);
|
|
126
126
|
!editorView.hasFocus() && editorView.focus();
|
|
127
127
|
if (!createAnnotationResult) {
|
|
128
128
|
throw new Error('Failed to create annotation');
|
|
@@ -135,7 +135,7 @@ function InlineCommentView(_ref) {
|
|
|
135
135
|
return (
|
|
136
136
|
// This is called when optimistic create inline comment encounters an error,
|
|
137
137
|
// in which case the optimistically added annotation must be removed.
|
|
138
|
-
(0, _editorCommands.removeInlineCommentNearSelection)(id, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch)
|
|
138
|
+
(0, _editorCommands.removeInlineCommentNearSelection)(id, inlineCommentProvider.supportedBlockNodes, inlineCommentProvider.isBlockNodeSupported)(editorView.state, editorView.dispatch)
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
@@ -204,7 +204,7 @@ function InlineCommentView(_ref) {
|
|
|
204
204
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
205
205
|
,
|
|
206
206
|
onDelete: function onDelete(id) {
|
|
207
|
-
return (0, _editorCommands.removeInlineCommentNearSelection)(id, inlineCommentProvider.supportedBlockNodes)(editorView.state, dispatch);
|
|
207
|
+
return (0, _editorCommands.removeInlineCommentNearSelection)(id, inlineCommentProvider.supportedBlockNodes, inlineCommentProvider.isBlockNodeSupported)(editorView.state, dispatch);
|
|
208
208
|
}
|
|
209
209
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
210
210
|
,
|
|
@@ -71,8 +71,8 @@ export const annotationPlugin = ({
|
|
|
71
71
|
var _api$analytics2, _annotationProviders$;
|
|
72
72
|
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$ = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes) !== null && _annotationProviders$ !== void 0 ? _annotationProviders$ : []);
|
|
73
73
|
},
|
|
74
|
-
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),
|
|
75
|
-
showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
|
|
74
|
+
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),
|
|
75
|
+
showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
|
|
76
76
|
setSelectedAnnotation,
|
|
77
77
|
setPendingSelectedAnnotation
|
|
78
78
|
},
|
|
@@ -58,12 +58,13 @@ export const setPendingSelectedAnnotation = id => createCommand({
|
|
|
58
58
|
}]
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
|
-
const removeInlineCommentFromNode = (id, supportedBlockNodes = [], state, dispatch) => {
|
|
61
|
+
const removeInlineCommentFromNode = (id, supportedBlockNodes = [], isBlockNodeSupported, state, dispatch) => {
|
|
62
62
|
const {
|
|
63
63
|
tr,
|
|
64
64
|
selection
|
|
65
65
|
} = state;
|
|
66
|
-
|
|
66
|
+
const selectedNodeIsSupported = selection instanceof NodeSelection && (isSupportedBlockNode(selection.node, supportedBlockNodes, isBlockNodeSupported) || selection.node.type === state.schema.nodes.mediaSingle && !!selection.node.firstChild && isSupportedBlockNode(selection.node.firstChild, supportedBlockNodes, isBlockNodeSupported));
|
|
67
|
+
if (selectedNodeIsSupported) {
|
|
67
68
|
const {
|
|
68
69
|
$from
|
|
69
70
|
} = selection;
|
|
@@ -93,14 +94,14 @@ const removeInlineCommentFromNode = (id, supportedBlockNodes = [], state, dispat
|
|
|
93
94
|
}
|
|
94
95
|
return false;
|
|
95
96
|
};
|
|
96
|
-
export const removeInlineCommentNearSelection = (id, supportedNodes = []) => (state, dispatch) => {
|
|
97
|
+
export const removeInlineCommentNearSelection = (id, supportedNodes = [], isBlockNodeSupported) => (state, dispatch) => {
|
|
97
98
|
const {
|
|
98
99
|
tr,
|
|
99
100
|
selection: {
|
|
100
101
|
$from
|
|
101
102
|
}
|
|
102
103
|
} = state;
|
|
103
|
-
if (removeInlineCommentFromNode(id, supportedNodes, state, dispatch)) {
|
|
104
|
+
if (removeInlineCommentFromNode(id, supportedNodes, isBlockNodeSupported, state, dispatch)) {
|
|
104
105
|
return true;
|
|
105
106
|
}
|
|
106
107
|
const {
|
|
@@ -121,7 +122,7 @@ export const removeInlineCommentNearSelection = (id, supportedNodes = []) => (st
|
|
|
121
122
|
}
|
|
122
123
|
return true;
|
|
123
124
|
};
|
|
124
|
-
export const removeInlineCommentFromDoc = editorAnalyticsAPI => (id, supportedNodes = []) => (state, dispatch) => {
|
|
125
|
+
export const removeInlineCommentFromDoc = editorAnalyticsAPI => (id, supportedNodes = [], isBlockNodeSupported) => (state, dispatch) => {
|
|
125
126
|
const {
|
|
126
127
|
tr
|
|
127
128
|
} = state;
|
|
@@ -131,9 +132,9 @@ export const removeInlineCommentFromDoc = editorAnalyticsAPI => (id, supportedNo
|
|
|
131
132
|
if (node.type.name === 'mediaInline') {
|
|
132
133
|
return false;
|
|
133
134
|
}
|
|
134
|
-
const
|
|
135
|
+
const isSupportedBlock = node.isBlock && isSupportedBlockNode(node, supportedNodes, isBlockNodeSupported);
|
|
135
136
|
node.marks.filter(mark => mark.type === state.schema.marks.annotation && mark.attrs.id === id).forEach(mark => {
|
|
136
|
-
if (
|
|
137
|
+
if (isSupportedBlock) {
|
|
137
138
|
tr.removeNodeMark(pos, mark);
|
|
138
139
|
} else {
|
|
139
140
|
tr.removeMark(pos, pos + node.nodeSize, mark);
|
|
@@ -146,10 +147,10 @@ export const removeInlineCommentFromDoc = editorAnalyticsAPI => (id, supportedNo
|
|
|
146
147
|
}
|
|
147
148
|
return false;
|
|
148
149
|
};
|
|
149
|
-
const getDraftCommandAction = (drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar) => {
|
|
150
|
+
const getDraftCommandAction = (drafting, targetType, targetNodeId, supportedBlockNodes, isBlockNodeSupported, isOpeningMediaCommentFromToolbar) => {
|
|
150
151
|
return editorState => {
|
|
151
152
|
// validate selection only when entering draft mode
|
|
152
|
-
if (drafting && isSelectionValid(editorState) !== AnnotationSelectionType.VALID) {
|
|
153
|
+
if (drafting && isSelectionValid(editorState, supportedBlockNodes, isBlockNodeSupported) !== AnnotationSelectionType.VALID) {
|
|
153
154
|
return false;
|
|
154
155
|
}
|
|
155
156
|
return {
|
|
@@ -159,6 +160,7 @@ const getDraftCommandAction = (drafting, targetType, targetNodeId, supportedBloc
|
|
|
159
160
|
editorState,
|
|
160
161
|
targetType,
|
|
161
162
|
supportedBlockNodes,
|
|
163
|
+
isBlockNodeSupported,
|
|
162
164
|
targetNodeId,
|
|
163
165
|
isOpeningMediaCommentFromToolbar
|
|
164
166
|
}
|
|
@@ -172,12 +174,12 @@ const getDraftCommandAction = (drafting, targetType, targetNodeId, supportedBloc
|
|
|
172
174
|
* @param supportedBlockNodes
|
|
173
175
|
* @example
|
|
174
176
|
*/
|
|
175
|
-
export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node, viewMethod, isOpeningMediaCommentFromToolbar) => (state, dispatch) => {
|
|
177
|
+
export const showInlineCommentForBlockNode = (supportedBlockNodes = [], isBlockNodeSupported) => (node, viewMethod, isOpeningMediaCommentFromToolbar) => (state, dispatch) => {
|
|
176
178
|
const pluginState = getPluginState(state);
|
|
177
179
|
const {
|
|
178
180
|
annotation
|
|
179
181
|
} = state.schema.marks;
|
|
180
|
-
if (node && node.isBlock &&
|
|
182
|
+
if (node && node.isBlock && isSupportedBlockNode(node, supportedBlockNodes, isBlockNodeSupported)) {
|
|
181
183
|
const unresolvedAnnotationMarks = ((node === null || node === void 0 ? void 0 : node.marks) || []).filter(mark => mark.type === annotation && !(pluginState !== null && pluginState !== void 0 && pluginState.annotations[mark.attrs.id])).map(mark => ({
|
|
182
184
|
id: mark.attrs.id,
|
|
183
185
|
type: mark.attrs.annotationType
|
|
@@ -201,8 +203,8 @@ export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node
|
|
|
201
203
|
}
|
|
202
204
|
return false;
|
|
203
205
|
};
|
|
204
|
-
export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = [], api) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', targetNodeId = undefined, isOpeningMediaCommentFromToolbar) => {
|
|
205
|
-
const commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar);
|
|
206
|
+
export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = [], api, isBlockNodeSupported) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', targetNodeId = undefined, isOpeningMediaCommentFromToolbar) => {
|
|
207
|
+
const commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isBlockNodeSupported, isOpeningMediaCommentFromToolbar);
|
|
206
208
|
if (Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) {
|
|
207
209
|
return (state, dispatch) => {
|
|
208
210
|
const tr = transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod)(state.tr, state);
|
|
@@ -226,7 +228,7 @@ export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNod
|
|
|
226
228
|
return createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
|
|
227
229
|
}
|
|
228
230
|
};
|
|
229
|
-
export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes) => {
|
|
231
|
+
export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes, isBlockNodeSupported) => {
|
|
230
232
|
const commandAction = editorState => ({
|
|
231
233
|
type: ACTIONS.ADD_INLINE_COMMENT,
|
|
232
234
|
data: {
|
|
@@ -245,7 +247,7 @@ export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supporte
|
|
|
245
247
|
});
|
|
246
248
|
if (Boolean(editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.toolbar)) {
|
|
247
249
|
return (state, dispatch) => {
|
|
248
|
-
const tr = transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes)(state.tr, state);
|
|
250
|
+
const tr = transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes, isBlockNodeSupported)(state.tr, state);
|
|
249
251
|
tr.setMeta(inlineCommentPluginKey, commandAction(state));
|
|
250
252
|
resetUserIntent(editorAPI, tr);
|
|
251
253
|
if (dispatch) {
|
|
@@ -255,7 +257,7 @@ export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supporte
|
|
|
255
257
|
return false;
|
|
256
258
|
};
|
|
257
259
|
} else {
|
|
258
|
-
return createCommand(commandAction, transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes));
|
|
260
|
+
return createCommand(commandAction, transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes, isBlockNodeSupported));
|
|
259
261
|
}
|
|
260
262
|
};
|
|
261
263
|
export const updateMouseState = mouseData => createCommand({
|
|
@@ -282,7 +284,7 @@ export const setHoveredAnnotation = id => createCommand({
|
|
|
282
284
|
}]
|
|
283
285
|
}
|
|
284
286
|
});
|
|
285
|
-
export const createAnnotation = (editorAnalyticsAPI, editorAPI) => (id, annotationType = AnnotationTypes.INLINE_COMMENT, supportedBlockNodes) => (state, dispatch) => {
|
|
287
|
+
export const createAnnotation = (editorAnalyticsAPI, editorAPI) => (id, annotationType = AnnotationTypes.INLINE_COMMENT, supportedBlockNodes, isBlockNodeSupported) => (state, dispatch) => {
|
|
286
288
|
// don't try to add if there are is no temp highlight bookmarked
|
|
287
289
|
const {
|
|
288
290
|
bookmark
|
|
@@ -291,7 +293,7 @@ export const createAnnotation = (editorAnalyticsAPI, editorAPI) => (id, annotati
|
|
|
291
293
|
return false;
|
|
292
294
|
}
|
|
293
295
|
if (annotationType === AnnotationTypes.INLINE_COMMENT) {
|
|
294
|
-
return addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes)(state, dispatch);
|
|
296
|
+
return addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes, isBlockNodeSupported)(state, dispatch);
|
|
295
297
|
}
|
|
296
298
|
return false;
|
|
297
299
|
};
|
|
@@ -7,7 +7,7 @@ import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
8
8
|
import { getDraftCommandAnalyticsPayload, getPluginState, resolveDraftBookmark } from '../pm-plugins/utils';
|
|
9
9
|
const isAnnotationStep = step => step instanceof AddMarkStep && step.mark.type.name === 'annotation';
|
|
10
|
-
const addAnnotationMark = (id, supportedBlockNodes) => (transaction, state) => {
|
|
10
|
+
const addAnnotationMark = (id, supportedBlockNodes, isBlockNodeSupported) => (transaction, state) => {
|
|
11
11
|
const inlineCommentState = getPluginState(state);
|
|
12
12
|
const {
|
|
13
13
|
bookmark
|
|
@@ -21,7 +21,7 @@ const addAnnotationMark = (id, supportedBlockNodes) => (transaction, state) => {
|
|
|
21
21
|
to,
|
|
22
22
|
head,
|
|
23
23
|
isBlockNode
|
|
24
|
-
} = resolveDraftBookmark(state, bookmark, supportedBlockNodes);
|
|
24
|
+
} = resolveDraftBookmark(state, bookmark, supportedBlockNodes, isBlockNodeSupported);
|
|
25
25
|
let tr = transaction;
|
|
26
26
|
if (isBlockNode) {
|
|
27
27
|
tr = tr.addNodeMark(from, annotationMark);
|
|
@@ -39,9 +39,9 @@ const addAnnotationMark = (id, supportedBlockNodes) => (transaction, state) => {
|
|
|
39
39
|
}
|
|
40
40
|
return tr;
|
|
41
41
|
};
|
|
42
|
-
const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes) => (transaction, state) => {
|
|
42
|
+
const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes, isBlockNodeSupported) => (transaction, state) => {
|
|
43
43
|
var _editorAPI$editorView, _pluginState$featureF;
|
|
44
|
-
let tr = addAnnotationMark(id, supportedBlockNodes)(transaction, state);
|
|
44
|
+
let tr = addAnnotationMark(id, supportedBlockNodes, isBlockNodeSupported)(transaction, state);
|
|
45
45
|
editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$editorView = editorAPI.editorViewModeEffects) === null || _editorAPI$editorView === void 0 ? void 0 : _editorAPI$editorView.actions.applyViewModeStepAt(tr);
|
|
46
46
|
|
|
47
47
|
// add insert analytics step to transaction
|
|
@@ -22,7 +22,7 @@ const domRefFromPos = (view, position) => {
|
|
|
22
22
|
}
|
|
23
23
|
return dom;
|
|
24
24
|
};
|
|
25
|
-
export const allowAnnotation = (editorView,
|
|
25
|
+
export const allowAnnotation = (editorView, options) => () => {
|
|
26
26
|
const {
|
|
27
27
|
isDrafting,
|
|
28
28
|
draftDecorationSet
|
|
@@ -36,7 +36,7 @@ export const allowAnnotation = (editorView, _options) => () => {
|
|
|
36
36
|
if (!!(decoration !== null && decoration !== void 0 && decoration.length)) {
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
|
-
return isSelectionValid(editorView.state) === AnnotationSelectionType.VALID;
|
|
39
|
+
return isSelectionValid(editorView.state, options.provider.supportedBlockNodes, options.provider.isBlockNodeSupported) === AnnotationSelectionType.VALID;
|
|
40
40
|
};
|
|
41
41
|
export const startDraft = (editorView, options) => () => {
|
|
42
42
|
var _getRangeInlineNodeNa, _options$annotationMa2;
|
|
@@ -68,7 +68,7 @@ export const startDraft = (editorView, options) => () => {
|
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
setInlineCommentDraftState(options.editorAnalyticsAPI,
|
|
71
|
+
setInlineCommentDraftState(options.editorAnalyticsAPI, options.provider.supportedBlockNodes, options.api, options.provider.isBlockNodeSupported)(true)(editorView.state, editorView.dispatch);
|
|
72
72
|
const {
|
|
73
73
|
draftDecorationSet
|
|
74
74
|
} = inlineCommentPluginKey.getState(editorView.state) || {};
|
|
@@ -151,7 +151,7 @@ export const applyDraft = (editorView, options) => id => {
|
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
153
|
const from = decorations[0].from;
|
|
154
|
-
createAnnotation(options.editorAnalyticsAPI, options.api)(id, AnnotationTypes.INLINE_COMMENT, options.provider.supportedBlockNodes)(editorView.state, editorView.dispatch);
|
|
154
|
+
createAnnotation(options.editorAnalyticsAPI, options.api)(id, AnnotationTypes.INLINE_COMMENT, options.provider.supportedBlockNodes, options.provider.isBlockNodeSupported)(editorView.state, editorView.dispatch);
|
|
155
155
|
!editorView.hasFocus() && editorView.focus();
|
|
156
156
|
|
|
157
157
|
// Using the original decoration from position we should be able to locate the new target element.
|
|
@@ -327,7 +327,7 @@ export const clearAnnotation = (editorView, options) => id => {
|
|
|
327
327
|
reason: ERROR_REASON_ID_INVALID
|
|
328
328
|
};
|
|
329
329
|
}
|
|
330
|
-
removeInlineCommentFromDoc(options.editorAnalyticsAPI)(id, options.provider.supportedBlockNodes)(editorView.state, editorView.dispatch);
|
|
330
|
+
removeInlineCommentFromDoc(options.editorAnalyticsAPI)(id, options.provider.supportedBlockNodes, options.provider.isBlockNodeSupported)(editorView.state, editorView.dispatch);
|
|
331
331
|
return {
|
|
332
332
|
success: true,
|
|
333
333
|
actionResult: undefined
|