@atlaskit/editor-plugin-annotation 19.1.0 → 19.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -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 +7 -3
|
@@ -10,7 +10,7 @@ import { getAnnotationViewClassname, getBlockAnnotationViewClassname } from '../
|
|
|
10
10
|
import { allowAnnotation, applyDraft, clearDraft, clearAnnotation, getDraft, setIsAnnotationHovered, setIsAnnotationSelected, startDraft } from './annotation-manager-hooks';
|
|
11
11
|
import { createPluginState } from './plugin-factory';
|
|
12
12
|
import { shouldSuppressFloatingToolbar } from './toolbar';
|
|
13
|
-
import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from './utils';
|
|
13
|
+
import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey, isSupportedBlockNode } from './utils';
|
|
14
14
|
const fetchProviderStates = async (provider, annotationIds) => {
|
|
15
15
|
if (!provider || !provider.getState) {
|
|
16
16
|
return {};
|
|
@@ -409,19 +409,18 @@ export const inlineCommentPlugin = options => {
|
|
|
409
409
|
// everytime we need to update the decorations. This handler will be called alot. We should be caching
|
|
410
410
|
// the decorations in plugin state and only updating them when required.
|
|
411
411
|
state.doc.descendants((node, pos) => {
|
|
412
|
-
var _provider$supportedBl;
|
|
413
412
|
// Inline comment on mediaInline is not supported as part of comments on media project
|
|
414
413
|
// Thus, we skip the decoration for mediaInline node
|
|
415
414
|
if (node.type.name === 'mediaInline') {
|
|
416
415
|
return false;
|
|
417
416
|
}
|
|
418
|
-
const
|
|
417
|
+
const isSupportedBlock = node.isBlock && isSupportedBlockNode(node, provider.supportedBlockNodes, provider.isBlockNodeSupported);
|
|
419
418
|
node.marks.filter(mark => mark.type === state.schema.marks.annotation).forEach(mark => {
|
|
420
419
|
if (isVisible) {
|
|
421
420
|
const isUnresolved = !!annotations && annotations[mark.attrs.id] === false;
|
|
422
421
|
const isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(selectedAnnotation => selectedAnnotation.id === mark.attrs.id));
|
|
423
422
|
const isHovered = !isInlineCommentViewClosed && !!(hoveredAnnotations !== null && hoveredAnnotations !== void 0 && hoveredAnnotations.some(hoveredAnnotation => hoveredAnnotation.id === mark.attrs.id));
|
|
424
|
-
if (
|
|
423
|
+
if (isSupportedBlock) {
|
|
425
424
|
focusDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
426
425
|
class: `${getBlockAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`
|
|
427
426
|
}, {
|
|
@@ -24,7 +24,7 @@ export default ((pluginState, action) => {
|
|
|
24
24
|
mouseData
|
|
25
25
|
};
|
|
26
26
|
case ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
|
|
27
|
-
return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.supportedBlockNodes, action.data.targetNodeId, action.data.isOpeningMediaCommentFromToolbar);
|
|
27
|
+
return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.supportedBlockNodes, action.data.isBlockNodeSupported, action.data.targetNodeId, action.data.isOpeningMediaCommentFromToolbar);
|
|
28
28
|
case ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
|
|
29
29
|
return {
|
|
30
30
|
...pluginState,
|
|
@@ -100,7 +100,7 @@ export default ((pluginState, action) => {
|
|
|
100
100
|
return pluginState;
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
|
-
function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, targetNodeId, isOpeningMediaCommentFromToolbar) {
|
|
103
|
+
function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, isBlockNodeSupported, targetNodeId, isOpeningMediaCommentFromToolbar) {
|
|
104
104
|
let {
|
|
105
105
|
draftDecorationSet
|
|
106
106
|
} = pluginState;
|
|
@@ -119,7 +119,7 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, suppor
|
|
|
119
119
|
const {
|
|
120
120
|
from,
|
|
121
121
|
to
|
|
122
|
-
} = resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes);
|
|
122
|
+
} = resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes, isBlockNodeSupported);
|
|
123
123
|
const draftDecoration = addDraftDecoration(from, to, targetType);
|
|
124
124
|
newState.draftDecorationSet = draftDecorationSet.add(editorState.doc, [draftDecoration]);
|
|
125
125
|
}
|
|
@@ -159,7 +159,7 @@ export const findAnnotationsInSelection = (selection, doc) => {
|
|
|
159
159
|
reorderAnnotations(annotations, $anchor);
|
|
160
160
|
return annotations;
|
|
161
161
|
};
|
|
162
|
-
export const resolveDraftBookmark = (editorState, bookmark, supportedBlockNodes = []) => {
|
|
162
|
+
export const resolveDraftBookmark = (editorState, bookmark, supportedBlockNodes = [], isBlockNodeSupported) => {
|
|
163
163
|
const {
|
|
164
164
|
doc
|
|
165
165
|
} = editorState;
|
|
@@ -185,7 +185,8 @@ export const resolveDraftBookmark = (editorState, bookmark, supportedBlockNodes
|
|
|
185
185
|
return false;
|
|
186
186
|
}
|
|
187
187
|
const nodeEndsAt = pos + node.nodeSize;
|
|
188
|
-
|
|
188
|
+
const isLegacyMediaSingleWrapper = node.type.name === 'mediaSingle' && supportedBlockNodes.includes('media') && !supportedBlockNodes.includes('mediaSingle');
|
|
189
|
+
if (isSupportedBlockNode(node, supportedBlockNodes, isBlockNodeSupported) && !isLegacyMediaSingleWrapper) {
|
|
189
190
|
draftBookmark = {
|
|
190
191
|
from: pos,
|
|
191
192
|
to: nodeEndsAt,
|
|
@@ -262,7 +263,7 @@ export const getDraftCommandAnalyticsPayload = (drafting, inputMethod) => {
|
|
|
262
263
|
};
|
|
263
264
|
return payload;
|
|
264
265
|
};
|
|
265
|
-
export const isSelectionValid = (state,
|
|
266
|
+
export const isSelectionValid = (state, supportedBlockNodes = [], isBlockNodeSupported) => {
|
|
266
267
|
var _currentMediaNodeWith;
|
|
267
268
|
const {
|
|
268
269
|
selection
|
|
@@ -273,7 +274,8 @@ export const isSelectionValid = (state, _supportedNodes = []) => {
|
|
|
273
274
|
const allowedInlineNodes = ['emoji', 'status', 'date', 'mention', 'inlineCard'];
|
|
274
275
|
const isSelectionEmpty = selection.empty;
|
|
275
276
|
const isTextOrAllSelection = selection instanceof TextSelection || selection instanceof AllSelection;
|
|
276
|
-
const
|
|
277
|
+
const isSupportedBlockNodeSelection = selection instanceof NodeSelection && isSupportedBlockNode(selection.node, supportedBlockNodes, isBlockNodeSupported);
|
|
278
|
+
const isValidNodeSelection = selection instanceof NodeSelection && (allowedInlineNodes.includes(selection.node.type.name) || isSupportedBlockNodeSelection);
|
|
277
279
|
const isValidSelection = isTextOrAllSelection || isValidNodeSelection;
|
|
278
280
|
|
|
279
281
|
// Allow media so that it can enter draft mode
|
|
@@ -283,7 +285,7 @@ export const isSelectionValid = (state, _supportedNodes = []) => {
|
|
|
283
285
|
if (isSelectionEmpty || !isValidSelection) {
|
|
284
286
|
return AnnotationSelectionType.INVALID;
|
|
285
287
|
}
|
|
286
|
-
const containsInvalidNodes = hasInvalidNodes(state);
|
|
288
|
+
const containsInvalidNodes = !isSupportedBlockNodeSelection && hasInvalidNodes(state);
|
|
287
289
|
|
|
288
290
|
// A selection that only covers 1 pos, and is an invalid node
|
|
289
291
|
// e.g. a text selection over a mention
|
|
@@ -312,8 +314,8 @@ export const hasInvalidNodes = state => {
|
|
|
312
314
|
to: selection.to
|
|
313
315
|
}, doc, schema);
|
|
314
316
|
};
|
|
315
|
-
export const isSupportedBlockNode = (node, supportedBlockNodes = []) => {
|
|
316
|
-
return supportedBlockNodes.indexOf(node.type.name) >= 0 || node.type.name === 'mediaSingle' && supportedBlockNodes.indexOf('media') >= 0;
|
|
317
|
+
export const isSupportedBlockNode = (node, supportedBlockNodes = [], isBlockNodeSupported) => {
|
|
318
|
+
return supportedBlockNodes.indexOf(node.type.name) >= 0 || node.type.name === 'mediaSingle' && supportedBlockNodes.indexOf('media') >= 0 || fg('cc_maui_annotations_on_extensions') && (isBlockNodeSupported === null || isBlockNodeSupported === void 0 ? void 0 : isBlockNodeSupported(node)) === true;
|
|
317
319
|
};
|
|
318
320
|
|
|
319
321
|
/**
|
|
@@ -122,7 +122,7 @@ export function InlineCommentView({
|
|
|
122
122
|
,
|
|
123
123
|
onCreate: id => {
|
|
124
124
|
if (!isAnnotationManagerEnabled) {
|
|
125
|
-
const createAnnotationResult = createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
|
|
125
|
+
const createAnnotationResult = createAnnotation(editorAnalyticsAPI, editorAPI)(id, 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');
|
|
@@ -134,7 +134,7 @@ export function InlineCommentView({
|
|
|
134
134
|
onCreateError: id =>
|
|
135
135
|
// This is called when optimistic create inline comment encounters an error,
|
|
136
136
|
// in which case the optimistically added annotation must be removed.
|
|
137
|
-
removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch)
|
|
137
|
+
removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes, inlineCommentProvider.isBlockNodeSupported)(editorView.state, editorView.dispatch)
|
|
138
138
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
139
139
|
,
|
|
140
140
|
onClose: () => {
|
|
@@ -196,7 +196,7 @@ export function InlineCommentView({
|
|
|
196
196
|
dom: dom
|
|
197
197
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
198
198
|
,
|
|
199
|
-
onDelete: id => removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(editorView.state, dispatch)
|
|
199
|
+
onDelete: id => removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes, inlineCommentProvider.isBlockNodeSupported)(editorView.state, dispatch)
|
|
200
200
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
201
201
|
,
|
|
202
202
|
onResolve: id => updateInlineCommentResolvedState(editorAnalyticsAPI)({
|
|
@@ -96,8 +96,8 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
96
96
|
var _api$analytics2, _annotationProviders$;
|
|
97
97
|
return 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$ : []);
|
|
98
98
|
},
|
|
99
|
-
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),
|
|
100
|
-
showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
|
|
99
|
+
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),
|
|
100
|
+
showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
|
|
101
101
|
setSelectedAnnotation: setSelectedAnnotation,
|
|
102
102
|
setPendingSelectedAnnotation: setPendingSelectedAnnotation
|
|
103
103
|
},
|
|
@@ -81,11 +81,13 @@ export var setPendingSelectedAnnotation = function setPendingSelectedAnnotation(
|
|
|
81
81
|
};
|
|
82
82
|
var removeInlineCommentFromNode = function removeInlineCommentFromNode(id) {
|
|
83
83
|
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
84
|
-
var
|
|
85
|
-
var
|
|
84
|
+
var isBlockNodeSupported = arguments.length > 2 ? arguments[2] : undefined;
|
|
85
|
+
var state = arguments.length > 3 ? arguments[3] : undefined;
|
|
86
|
+
var dispatch = arguments.length > 4 ? arguments[4] : undefined;
|
|
86
87
|
var tr = state.tr,
|
|
87
88
|
selection = state.selection;
|
|
88
|
-
|
|
89
|
+
var 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));
|
|
90
|
+
if (selectedNodeIsSupported) {
|
|
89
91
|
var $from = selection.$from;
|
|
90
92
|
var currNode = selection.node;
|
|
91
93
|
var from = $from.start();
|
|
@@ -115,10 +117,11 @@ var removeInlineCommentFromNode = function removeInlineCommentFromNode(id) {
|
|
|
115
117
|
};
|
|
116
118
|
export var removeInlineCommentNearSelection = function removeInlineCommentNearSelection(id) {
|
|
117
119
|
var supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
120
|
+
var isBlockNodeSupported = arguments.length > 2 ? arguments[2] : undefined;
|
|
118
121
|
return function (state, dispatch) {
|
|
119
122
|
var tr = state.tr,
|
|
120
123
|
$from = state.selection.$from;
|
|
121
|
-
if (removeInlineCommentFromNode(id, supportedNodes, state, dispatch)) {
|
|
124
|
+
if (removeInlineCommentFromNode(id, supportedNodes, isBlockNodeSupported, state, dispatch)) {
|
|
122
125
|
return true;
|
|
123
126
|
}
|
|
124
127
|
var annotationMarkType = state.schema.marks.annotation;
|
|
@@ -143,6 +146,7 @@ export var removeInlineCommentNearSelection = function removeInlineCommentNearSe
|
|
|
143
146
|
export var removeInlineCommentFromDoc = function removeInlineCommentFromDoc(editorAnalyticsAPI) {
|
|
144
147
|
return function (id) {
|
|
145
148
|
var supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
149
|
+
var isBlockNodeSupported = arguments.length > 2 ? arguments[2] : undefined;
|
|
146
150
|
return function (state, dispatch) {
|
|
147
151
|
var tr = state.tr;
|
|
148
152
|
state.doc.descendants(function (node, pos) {
|
|
@@ -151,11 +155,11 @@ export var removeInlineCommentFromDoc = function removeInlineCommentFromDoc(edit
|
|
|
151
155
|
if (node.type.name === 'mediaInline') {
|
|
152
156
|
return false;
|
|
153
157
|
}
|
|
154
|
-
var
|
|
158
|
+
var isSupportedBlock = node.isBlock && isSupportedBlockNode(node, supportedNodes, isBlockNodeSupported);
|
|
155
159
|
node.marks.filter(function (mark) {
|
|
156
160
|
return mark.type === state.schema.marks.annotation && mark.attrs.id === id;
|
|
157
161
|
}).forEach(function (mark) {
|
|
158
|
-
if (
|
|
162
|
+
if (isSupportedBlock) {
|
|
159
163
|
tr.removeNodeMark(pos, mark);
|
|
160
164
|
} else {
|
|
161
165
|
tr.removeMark(pos, pos + node.nodeSize, mark);
|
|
@@ -170,10 +174,10 @@ export var removeInlineCommentFromDoc = function removeInlineCommentFromDoc(edit
|
|
|
170
174
|
};
|
|
171
175
|
};
|
|
172
176
|
};
|
|
173
|
-
var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar) {
|
|
177
|
+
var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isBlockNodeSupported, isOpeningMediaCommentFromToolbar) {
|
|
174
178
|
return function (editorState) {
|
|
175
179
|
// validate selection only when entering draft mode
|
|
176
|
-
if (drafting && isSelectionValid(editorState) !== AnnotationSelectionType.VALID) {
|
|
180
|
+
if (drafting && isSelectionValid(editorState, supportedBlockNodes, isBlockNodeSupported) !== AnnotationSelectionType.VALID) {
|
|
177
181
|
return false;
|
|
178
182
|
}
|
|
179
183
|
return {
|
|
@@ -183,6 +187,7 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
|
|
|
183
187
|
editorState: editorState,
|
|
184
188
|
targetType: targetType,
|
|
185
189
|
supportedBlockNodes: supportedBlockNodes,
|
|
190
|
+
isBlockNodeSupported: isBlockNodeSupported,
|
|
186
191
|
targetNodeId: targetNodeId,
|
|
187
192
|
isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
|
|
188
193
|
}
|
|
@@ -198,11 +203,12 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
|
|
|
198
203
|
*/
|
|
199
204
|
export var showInlineCommentForBlockNode = function showInlineCommentForBlockNode() {
|
|
200
205
|
var supportedBlockNodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
206
|
+
var isBlockNodeSupported = arguments.length > 1 ? arguments[1] : undefined;
|
|
201
207
|
return function (node, viewMethod, isOpeningMediaCommentFromToolbar) {
|
|
202
208
|
return function (state, dispatch) {
|
|
203
209
|
var pluginState = getPluginState(state);
|
|
204
210
|
var annotation = state.schema.marks.annotation;
|
|
205
|
-
if (node && node.isBlock &&
|
|
211
|
+
if (node && node.isBlock && isSupportedBlockNode(node, supportedBlockNodes, isBlockNodeSupported)) {
|
|
206
212
|
var unresolvedAnnotationMarks = ((node === null || node === void 0 ? void 0 : node.marks) || []).filter(function (mark) {
|
|
207
213
|
return mark.type === annotation && !(pluginState !== null && pluginState !== void 0 && pluginState.annotations[mark.attrs.id]);
|
|
208
214
|
}).map(function (mark) {
|
|
@@ -235,12 +241,13 @@ export var showInlineCommentForBlockNode = function showInlineCommentForBlockNod
|
|
|
235
241
|
export var setInlineCommentDraftState = function setInlineCommentDraftState(editorAnalyticsAPI) {
|
|
236
242
|
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
237
243
|
var api = arguments.length > 2 ? arguments[2] : undefined;
|
|
244
|
+
var isBlockNodeSupported = arguments.length > 3 ? arguments[3] : undefined;
|
|
238
245
|
return function (drafting) {
|
|
239
246
|
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
|
|
240
247
|
var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
|
|
241
248
|
var targetNodeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
242
249
|
var isOpeningMediaCommentFromToolbar = arguments.length > 4 ? arguments[4] : undefined;
|
|
243
|
-
var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar);
|
|
250
|
+
var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isBlockNodeSupported, isOpeningMediaCommentFromToolbar);
|
|
244
251
|
if (Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) {
|
|
245
252
|
return function (state, dispatch) {
|
|
246
253
|
var tr = transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod)(state.tr, state);
|
|
@@ -266,7 +273,7 @@ export var setInlineCommentDraftState = function setInlineCommentDraftState(edit
|
|
|
266
273
|
};
|
|
267
274
|
};
|
|
268
275
|
export var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
|
|
269
|
-
return function (id, supportedBlockNodes) {
|
|
276
|
+
return function (id, supportedBlockNodes, isBlockNodeSupported) {
|
|
270
277
|
var commandAction = function commandAction(editorState) {
|
|
271
278
|
return {
|
|
272
279
|
type: ACTIONS.ADD_INLINE_COMMENT,
|
|
@@ -285,7 +292,7 @@ export var addInlineComment = function addInlineComment(editorAnalyticsAPI, edit
|
|
|
285
292
|
};
|
|
286
293
|
if (Boolean(editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.toolbar)) {
|
|
287
294
|
return function (state, dispatch) {
|
|
288
|
-
var tr = transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes)(state.tr, state);
|
|
295
|
+
var tr = transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes, isBlockNodeSupported)(state.tr, state);
|
|
289
296
|
tr.setMeta(inlineCommentPluginKey, commandAction(state));
|
|
290
297
|
resetUserIntent(editorAPI, tr);
|
|
291
298
|
if (dispatch) {
|
|
@@ -295,7 +302,7 @@ export var addInlineComment = function addInlineComment(editorAnalyticsAPI, edit
|
|
|
295
302
|
return false;
|
|
296
303
|
};
|
|
297
304
|
} else {
|
|
298
|
-
return createCommand(commandAction, transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes));
|
|
305
|
+
return createCommand(commandAction, transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes, isBlockNodeSupported));
|
|
299
306
|
}
|
|
300
307
|
};
|
|
301
308
|
};
|
|
@@ -333,6 +340,7 @@ export var createAnnotation = function createAnnotation(editorAnalyticsAPI, edit
|
|
|
333
340
|
return function (id) {
|
|
334
341
|
var annotationType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : AnnotationTypes.INLINE_COMMENT;
|
|
335
342
|
var supportedBlockNodes = arguments.length > 2 ? arguments[2] : undefined;
|
|
343
|
+
var isBlockNodeSupported = arguments.length > 3 ? arguments[3] : undefined;
|
|
336
344
|
return function (state, dispatch) {
|
|
337
345
|
// don't try to add if there are is no temp highlight bookmarked
|
|
338
346
|
var _ref = getPluginState(state) || {},
|
|
@@ -341,7 +349,7 @@ export var createAnnotation = function createAnnotation(editorAnalyticsAPI, edit
|
|
|
341
349
|
return false;
|
|
342
350
|
}
|
|
343
351
|
if (annotationType === AnnotationTypes.INLINE_COMMENT) {
|
|
344
|
-
return addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes)(state, dispatch);
|
|
352
|
+
return addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes, isBlockNodeSupported)(state, dispatch);
|
|
345
353
|
}
|
|
346
354
|
return false;
|
|
347
355
|
};
|
|
@@ -9,7 +9,7 @@ import { getDraftCommandAnalyticsPayload, getPluginState, resolveDraftBookmark }
|
|
|
9
9
|
var isAnnotationStep = function isAnnotationStep(step) {
|
|
10
10
|
return step instanceof AddMarkStep && step.mark.type.name === 'annotation';
|
|
11
11
|
};
|
|
12
|
-
var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
|
|
12
|
+
var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes, isBlockNodeSupported) {
|
|
13
13
|
return function (transaction, state) {
|
|
14
14
|
var inlineCommentState = getPluginState(state);
|
|
15
15
|
var _ref = inlineCommentState || {},
|
|
@@ -18,7 +18,7 @@ var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
|
|
|
18
18
|
id: id,
|
|
19
19
|
type: AnnotationTypes.INLINE_COMMENT
|
|
20
20
|
});
|
|
21
|
-
var _resolveDraftBookmark = resolveDraftBookmark(state, bookmark, supportedBlockNodes),
|
|
21
|
+
var _resolveDraftBookmark = resolveDraftBookmark(state, bookmark, supportedBlockNodes, isBlockNodeSupported),
|
|
22
22
|
from = _resolveDraftBookmark.from,
|
|
23
23
|
to = _resolveDraftBookmark.to,
|
|
24
24
|
head = _resolveDraftBookmark.head,
|
|
@@ -42,10 +42,10 @@ var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
|
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
44
|
var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
|
|
45
|
-
return function (id, supportedBlockNodes) {
|
|
45
|
+
return function (id, supportedBlockNodes, isBlockNodeSupported) {
|
|
46
46
|
return function (transaction, state) {
|
|
47
47
|
var _editorAPI$editorView, _pluginState$featureF;
|
|
48
|
-
var tr = addAnnotationMark(id, supportedBlockNodes)(transaction, state);
|
|
48
|
+
var tr = addAnnotationMark(id, supportedBlockNodes, isBlockNodeSupported)(transaction, state);
|
|
49
49
|
editorAPI === null || editorAPI === void 0 || (_editorAPI$editorView = editorAPI.editorViewModeEffects) === null || _editorAPI$editorView === void 0 || _editorAPI$editorView.actions.applyViewModeStepAt(tr);
|
|
50
50
|
|
|
51
51
|
// add insert analytics step to transaction
|
|
@@ -22,7 +22,7 @@ var domRefFromPos = function domRefFromPos(view, position) {
|
|
|
22
22
|
}
|
|
23
23
|
return dom;
|
|
24
24
|
};
|
|
25
|
-
export var allowAnnotation = function allowAnnotation(editorView,
|
|
25
|
+
export var allowAnnotation = function allowAnnotation(editorView, options) {
|
|
26
26
|
return function () {
|
|
27
27
|
var _ref = inlineCommentPluginKey.getState(editorView.state) || {},
|
|
28
28
|
isDrafting = _ref.isDrafting,
|
|
@@ -36,7 +36,7 @@ export var allowAnnotation = function 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
|
};
|
|
42
42
|
export var startDraft = function startDraft(editorView, options) {
|
|
@@ -69,7 +69,7 @@ export var startDraft = function startDraft(editorView, options) {
|
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
setInlineCommentDraftState(options.editorAnalyticsAPI,
|
|
72
|
+
setInlineCommentDraftState(options.editorAnalyticsAPI, options.provider.supportedBlockNodes, options.api, options.provider.isBlockNodeSupported)(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();
|
|
@@ -153,7 +153,7 @@ export var applyDraft = function applyDraft(editorView, options) {
|
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
var from = decorations[0].from;
|
|
156
|
-
createAnnotation(options.editorAnalyticsAPI, options.api)(id, AnnotationTypes.INLINE_COMMENT, options.provider.supportedBlockNodes)(editorView.state, editorView.dispatch);
|
|
156
|
+
createAnnotation(options.editorAnalyticsAPI, options.api)(id, AnnotationTypes.INLINE_COMMENT, options.provider.supportedBlockNodes, options.provider.isBlockNodeSupported)(editorView.state, editorView.dispatch);
|
|
157
157
|
!editorView.hasFocus() && editorView.focus();
|
|
158
158
|
|
|
159
159
|
// Using the original decoration from position we should be able to locate the new target element.
|
|
@@ -337,7 +337,7 @@ export var clearAnnotation = function clearAnnotation(editorView, options) {
|
|
|
337
337
|
reason: ERROR_REASON_ID_INVALID
|
|
338
338
|
};
|
|
339
339
|
}
|
|
340
|
-
removeInlineCommentFromDoc(options.editorAnalyticsAPI)(id, options.provider.supportedBlockNodes)(editorView.state, editorView.dispatch);
|
|
340
|
+
removeInlineCommentFromDoc(options.editorAnalyticsAPI)(id, options.provider.supportedBlockNodes, options.provider.isBlockNodeSupported)(editorView.state, editorView.dispatch);
|
|
341
341
|
return {
|
|
342
342
|
success: true,
|
|
343
343
|
actionResult: undefined
|
|
@@ -13,7 +13,7 @@ import { getAnnotationViewClassname, getBlockAnnotationViewClassname } from '../
|
|
|
13
13
|
import { allowAnnotation, applyDraft, clearDraft, clearAnnotation, getDraft, setIsAnnotationHovered, setIsAnnotationSelected, startDraft } from './annotation-manager-hooks';
|
|
14
14
|
import { createPluginState } from './plugin-factory';
|
|
15
15
|
import { shouldSuppressFloatingToolbar } from './toolbar';
|
|
16
|
-
import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from './utils';
|
|
16
|
+
import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey, isSupportedBlockNode } from './utils';
|
|
17
17
|
var fetchProviderStates = /*#__PURE__*/function () {
|
|
18
18
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(provider, annotationIds) {
|
|
19
19
|
var data, result;
|
|
@@ -460,13 +460,12 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
460
460
|
// everytime we need to update the decorations. This handler will be called alot. We should be caching
|
|
461
461
|
// the decorations in plugin state and only updating them when required.
|
|
462
462
|
state.doc.descendants(function (node, pos) {
|
|
463
|
-
var _provider$supportedBl;
|
|
464
463
|
// Inline comment on mediaInline is not supported as part of comments on media project
|
|
465
464
|
// Thus, we skip the decoration for mediaInline node
|
|
466
465
|
if (node.type.name === 'mediaInline') {
|
|
467
466
|
return false;
|
|
468
467
|
}
|
|
469
|
-
var
|
|
468
|
+
var isSupportedBlock = node.isBlock && isSupportedBlockNode(node, provider.supportedBlockNodes, provider.isBlockNodeSupported);
|
|
470
469
|
node.marks.filter(function (mark) {
|
|
471
470
|
return mark.type === state.schema.marks.annotation;
|
|
472
471
|
}).forEach(function (mark) {
|
|
@@ -478,7 +477,7 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
478
477
|
var isHovered = !isInlineCommentViewClosed && !!(hoveredAnnotations !== null && hoveredAnnotations !== void 0 && hoveredAnnotations.some(function (hoveredAnnotation) {
|
|
479
478
|
return hoveredAnnotation.id === mark.attrs.id;
|
|
480
479
|
}));
|
|
481
|
-
if (
|
|
480
|
+
if (isSupportedBlock) {
|
|
482
481
|
focusDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
483
482
|
class: "".concat(getBlockAnnotationViewClassname(isUnresolved, isSelected), " ").concat(isUnresolved)
|
|
484
483
|
}, {
|
|
@@ -22,7 +22,7 @@ export default (function (pluginState, action) {
|
|
|
22
22
|
mouseData: mouseData
|
|
23
23
|
});
|
|
24
24
|
case ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
|
|
25
|
-
return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.supportedBlockNodes, action.data.targetNodeId, action.data.isOpeningMediaCommentFromToolbar);
|
|
25
|
+
return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.supportedBlockNodes, action.data.isBlockNodeSupported, action.data.targetNodeId, action.data.isOpeningMediaCommentFromToolbar);
|
|
26
26
|
case ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
|
|
27
27
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
28
28
|
dirtyAnnotations: false,
|
|
@@ -84,7 +84,7 @@ export default (function (pluginState, action) {
|
|
|
84
84
|
return pluginState;
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
|
-
function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, targetNodeId, isOpeningMediaCommentFromToolbar) {
|
|
87
|
+
function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, isBlockNodeSupported, targetNodeId, isOpeningMediaCommentFromToolbar) {
|
|
88
88
|
var draftDecorationSet = pluginState.draftDecorationSet;
|
|
89
89
|
if (!draftDecorationSet || !drafting) {
|
|
90
90
|
draftDecorationSet = DecorationSet.empty;
|
|
@@ -97,7 +97,7 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, suppor
|
|
|
97
97
|
newState.bookmark = undefined;
|
|
98
98
|
if (drafting && editorState) {
|
|
99
99
|
newState.bookmark = editorState.selection.getBookmark();
|
|
100
|
-
var _resolveDraftBookmark = resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes),
|
|
100
|
+
var _resolveDraftBookmark = resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes, isBlockNodeSupported),
|
|
101
101
|
from = _resolveDraftBookmark.from,
|
|
102
102
|
to = _resolveDraftBookmark.to;
|
|
103
103
|
var draftDecoration = addDraftDecoration(from, to, targetType);
|
|
@@ -185,6 +185,7 @@ export var findAnnotationsInSelection = function findAnnotationsInSelection(sele
|
|
|
185
185
|
};
|
|
186
186
|
export var resolveDraftBookmark = function resolveDraftBookmark(editorState, bookmark) {
|
|
187
187
|
var supportedBlockNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
188
|
+
var isBlockNodeSupported = arguments.length > 3 ? arguments[3] : undefined;
|
|
188
189
|
var doc = editorState.doc;
|
|
189
190
|
var resolvedBookmark = bookmark ? bookmark.resolve(doc) : editorState.selection;
|
|
190
191
|
var from = resolvedBookmark.from,
|
|
@@ -206,7 +207,8 @@ export var resolveDraftBookmark = function resolveDraftBookmark(editorState, boo
|
|
|
206
207
|
return false;
|
|
207
208
|
}
|
|
208
209
|
var nodeEndsAt = pos + node.nodeSize;
|
|
209
|
-
|
|
210
|
+
var isLegacyMediaSingleWrapper = node.type.name === 'mediaSingle' && supportedBlockNodes.includes('media') && !supportedBlockNodes.includes('mediaSingle');
|
|
211
|
+
if (isSupportedBlockNode(node, supportedBlockNodes, isBlockNodeSupported) && !isLegacyMediaSingleWrapper) {
|
|
210
212
|
draftBookmark = {
|
|
211
213
|
from: pos,
|
|
212
214
|
to: nodeEndsAt,
|
|
@@ -283,14 +285,16 @@ export var getDraftCommandAnalyticsPayload = function getDraftCommandAnalyticsPa
|
|
|
283
285
|
};
|
|
284
286
|
export var isSelectionValid = function isSelectionValid(state) {
|
|
285
287
|
var _currentMediaNodeWith;
|
|
286
|
-
var
|
|
288
|
+
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
289
|
+
var isBlockNodeSupported = arguments.length > 2 ? arguments[2] : undefined;
|
|
287
290
|
var selection = state.selection;
|
|
288
291
|
var _ref3 = getPluginState(state) || {},
|
|
289
292
|
disallowOnWhitespace = _ref3.disallowOnWhitespace;
|
|
290
293
|
var allowedInlineNodes = ['emoji', 'status', 'date', 'mention', 'inlineCard'];
|
|
291
294
|
var isSelectionEmpty = selection.empty;
|
|
292
295
|
var isTextOrAllSelection = selection instanceof TextSelection || selection instanceof AllSelection;
|
|
293
|
-
var
|
|
296
|
+
var isSupportedBlockNodeSelection = selection instanceof NodeSelection && isSupportedBlockNode(selection.node, supportedBlockNodes, isBlockNodeSupported);
|
|
297
|
+
var isValidNodeSelection = selection instanceof NodeSelection && (allowedInlineNodes.includes(selection.node.type.name) || isSupportedBlockNodeSelection);
|
|
294
298
|
var isValidSelection = isTextOrAllSelection || isValidNodeSelection;
|
|
295
299
|
|
|
296
300
|
// Allow media so that it can enter draft mode
|
|
@@ -300,7 +304,7 @@ export var isSelectionValid = function isSelectionValid(state) {
|
|
|
300
304
|
if (isSelectionEmpty || !isValidSelection) {
|
|
301
305
|
return AnnotationSelectionType.INVALID;
|
|
302
306
|
}
|
|
303
|
-
var containsInvalidNodes = hasInvalidNodes(state);
|
|
307
|
+
var containsInvalidNodes = !isSupportedBlockNodeSelection && hasInvalidNodes(state);
|
|
304
308
|
|
|
305
309
|
// A selection that only covers 1 pos, and is an invalid node
|
|
306
310
|
// e.g. a text selection over a mention
|
|
@@ -329,7 +333,8 @@ export var hasInvalidNodes = function hasInvalidNodes(state) {
|
|
|
329
333
|
};
|
|
330
334
|
export var isSupportedBlockNode = function isSupportedBlockNode(node) {
|
|
331
335
|
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
332
|
-
|
|
336
|
+
var isBlockNodeSupported = arguments.length > 2 ? arguments[2] : undefined;
|
|
337
|
+
return supportedBlockNodes.indexOf(node.type.name) >= 0 || node.type.name === 'mediaSingle' && supportedBlockNodes.indexOf('media') >= 0 || fg('cc_maui_annotations_on_extensions') && (isBlockNodeSupported === null || isBlockNodeSupported === void 0 ? void 0 : isBlockNodeSupported(node)) === true;
|
|
333
338
|
};
|
|
334
339
|
|
|
335
340
|
/**
|
|
@@ -115,7 +115,7 @@ export function InlineCommentView(_ref) {
|
|
|
115
115
|
,
|
|
116
116
|
onCreate: function onCreate(id) {
|
|
117
117
|
if (!isAnnotationManagerEnabled) {
|
|
118
|
-
var createAnnotationResult = createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
|
|
118
|
+
var createAnnotationResult = createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes, inlineCommentProvider.isBlockNodeSupported)(editorView.state, editorView.dispatch);
|
|
119
119
|
!editorView.hasFocus() && editorView.focus();
|
|
120
120
|
if (!createAnnotationResult) {
|
|
121
121
|
throw new Error('Failed to create annotation');
|
|
@@ -128,7 +128,7 @@ export function InlineCommentView(_ref) {
|
|
|
128
128
|
return (
|
|
129
129
|
// This is called when optimistic create inline comment encounters an error,
|
|
130
130
|
// in which case the optimistically added annotation must be removed.
|
|
131
|
-
removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch)
|
|
131
|
+
removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes, inlineCommentProvider.isBlockNodeSupported)(editorView.state, editorView.dispatch)
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
134
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
@@ -197,7 +197,7 @@ export function InlineCommentView(_ref) {
|
|
|
197
197
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
198
198
|
,
|
|
199
199
|
onDelete: function onDelete(id) {
|
|
200
|
-
return removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(editorView.state, dispatch);
|
|
200
|
+
return removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes, inlineCommentProvider.isBlockNodeSupported)(editorView.state, dispatch);
|
|
201
201
|
}
|
|
202
202
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
203
203
|
,
|
|
@@ -5,26 +5,26 @@ import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types
|
|
|
5
5
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import type { AnnotationPlugin } from '../annotationPluginType';
|
|
7
7
|
import type { InlineCommentMap, InlineCommentMouseData } from '../pm-plugins/types';
|
|
8
|
-
import type { InlineCommentInputMethod, TargetType } from '../types';
|
|
8
|
+
import type { InlineCommentAnnotationProvider, InlineCommentInputMethod, TargetType } from '../types';
|
|
9
9
|
export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
|
|
10
10
|
export declare const closeComponent: () => Command;
|
|
11
11
|
export declare const clearDirtyMark: () => Command;
|
|
12
12
|
export declare const setInlineCommentsFetched: () => Command;
|
|
13
13
|
export declare const flushPendingSelections: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (canSetAsSelectedAnnotations: boolean, errorReason?: string) => Command;
|
|
14
14
|
export declare const setPendingSelectedAnnotation: (id: string) => Command;
|
|
15
|
-
export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[]) => Command;
|
|
16
|
-
export declare const removeInlineCommentFromDoc: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (id: string, supportedNodes?: string[]) => Command;
|
|
15
|
+
export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => Command;
|
|
16
|
+
export declare const removeInlineCommentFromDoc: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (id: string, supportedNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => Command;
|
|
17
17
|
/**
|
|
18
18
|
* Show active inline comments for a given block node, otherwise,
|
|
19
19
|
* return false if the node has no comments or no unresolved comments.
|
|
20
20
|
* @param supportedBlockNodes
|
|
21
21
|
* @example
|
|
22
22
|
*/
|
|
23
|
-
export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null, viewMethod?: VIEW_METHOD, isOpeningMediaCommentFromToolbar?: boolean) => Command;
|
|
24
|
-
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[], api?: ExtractInjectionAPI<AnnotationPlugin
|
|
25
|
-
export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
|
|
23
|
+
export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => (node: PMNode | null, viewMethod?: VIEW_METHOD, isOpeningMediaCommentFromToolbar?: boolean) => Command;
|
|
24
|
+
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 addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => Command;
|
|
26
26
|
export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
|
|
27
27
|
export declare const setSelectedAnnotation: (id: string) => Command;
|
|
28
28
|
export declare const setHoveredAnnotation: (id: string) => Command;
|
|
29
|
-
export declare const createAnnotation: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, annotationType?: AnnotationTypes, supportedBlockNodes?: string[]) => Command;
|
|
29
|
+
export declare const createAnnotation: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, annotationType?: AnnotationTypes, supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => Command;
|
|
30
30
|
export declare const setInlineCommentsVisibility: (isVisible: boolean) => Command;
|
|
@@ -2,11 +2,11 @@ import type { EditorAnalyticsAPI, RESOLVE_METHOD } from '@atlaskit/editor-common
|
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { AnnotationPlugin } from '../annotationPluginType';
|
|
5
|
-
import type { InlineCommentInputMethod } from '../types';
|
|
5
|
+
import type { InlineCommentAnnotationProvider, InlineCommentInputMethod } from '../types';
|
|
6
6
|
declare const _default_1: {
|
|
7
|
-
addAnnotationMark: (id: string, supportedBlockNodes?: string[]) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
7
|
+
addAnnotationMark: (id: string, supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
8
8
|
addDeleteAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
9
|
-
addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
9
|
+
addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
10
10
|
addInsertAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
11
11
|
addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
12
12
|
addPreemptiveGateErrorAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (errorReason?: string) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
@@ -2,7 +2,7 @@ import { type AnnotationId } from '@atlaskit/adf-schema/annotation';
|
|
|
2
2
|
import type { ApplyDraftResult, ClearAnnotationResult, ClearDraftResult, GetDraftResult, HoverAnnotationResult, SelectAnnotationResult, StartDraftResult } from '@atlaskit/editor-common/annotation';
|
|
3
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { InlineCommentPluginOptions } from './types';
|
|
5
|
-
export declare const allowAnnotation: (editorView: EditorView,
|
|
5
|
+
export declare const allowAnnotation: (editorView: EditorView, options: InlineCommentPluginOptions) => () => boolean;
|
|
6
6
|
export declare const startDraft: (editorView: EditorView, options: InlineCommentPluginOptions) => () => StartDraftResult;
|
|
7
7
|
export declare const clearDraft: (editorView: EditorView, options: InlineCommentPluginOptions) => () => ClearDraftResult;
|
|
8
8
|
export declare const applyDraft: (editorView: EditorView, options: InlineCommentPluginOptions) => (id: AnnotationId) => ApplyDraftResult;
|
|
@@ -43,6 +43,7 @@ export type InlineCommentAction = {
|
|
|
43
43
|
data: {
|
|
44
44
|
drafting: boolean;
|
|
45
45
|
editorState: EditorState;
|
|
46
|
+
isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported'];
|
|
46
47
|
isOpeningMediaCommentFromToolbar?: boolean;
|
|
47
48
|
supportedBlockNodes?: string[];
|
|
48
49
|
targetNodeId?: string;
|