@atlaskit/editor-plugin-annotation 1.1.0 → 1.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 +12 -0
- package/dist/cjs/commands/index.js +8 -4
- package/dist/cjs/plugin.js +15 -11
- package/dist/cjs/pm-plugins/reducer.js +3 -3
- package/dist/cjs/toolbar.js +8 -2
- package/dist/cjs/types.js +7 -0
- package/dist/cjs/ui/InlineCommentView.js +1 -1
- package/dist/cjs/utils.js +15 -1
- package/dist/es2019/commands/index.js +7 -6
- package/dist/es2019/plugin.js +15 -11
- package/dist/es2019/pm-plugins/reducer.js +3 -3
- package/dist/es2019/toolbar.js +7 -3
- package/dist/es2019/types.js +9 -0
- package/dist/es2019/ui/InlineCommentView.js +1 -1
- package/dist/es2019/utils.js +14 -2
- package/dist/esm/commands/index.js +8 -4
- package/dist/esm/plugin.js +15 -11
- package/dist/esm/pm-plugins/reducer.js +3 -3
- package/dist/esm/toolbar.js +8 -2
- package/dist/esm/types.js +9 -0
- package/dist/esm/ui/InlineCommentView.js +1 -1
- package/dist/esm/utils.js +15 -1
- package/dist/types/commands/index.d.ts +3 -4
- package/dist/types/commands/transform.d.ts +11 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/pm-plugins/types.d.ts +2 -1
- package/dist/types/toolbar.d.ts +1 -1
- package/dist/types/types.d.ts +30 -2
- package/dist/types/utils.d.ts +5 -5
- package/dist/types-ts4.5/commands/index.d.ts +3 -4
- package/dist/types-ts4.5/commands/transform.d.ts +13 -4
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/types.d.ts +2 -1
- package/dist/types-ts4.5/toolbar.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +30 -2
- package/dist/types-ts4.5/utils.d.ts +5 -5
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 1.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#78577](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/78577) [`207fbd3685dc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/207fbd3685dc) - ED-22111 add supported nodes option to annotation plugin
|
|
8
|
+
|
|
9
|
+
## 1.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#78508](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/78508) [`1d2b9d7a0542`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1d2b9d7a0542) - Expose setInlineCommentDraftState as one of the annotation plugin actions, extend the action with the ability to apply comment highlight to node, and add optional plugin dependency, FeatureFlagsPlugin
|
|
14
|
+
|
|
3
15
|
## 1.1.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -39,6 +39,7 @@ var clearDirtyMark = exports.clearDirtyMark = function clearDirtyMark() {
|
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
var removeInlineCommentNearSelection = exports.removeInlineCommentNearSelection = function removeInlineCommentNearSelection(id) {
|
|
42
|
+
var _supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
42
43
|
return function (state, dispatch) {
|
|
43
44
|
var tr = state.tr,
|
|
44
45
|
$from = state.selection.$from;
|
|
@@ -61,17 +62,18 @@ var removeInlineCommentNearSelection = exports.removeInlineCommentNearSelection
|
|
|
61
62
|
return true;
|
|
62
63
|
};
|
|
63
64
|
};
|
|
64
|
-
var getDraftCommandAction = function getDraftCommandAction(drafting) {
|
|
65
|
+
var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, isCommentOnMediaOn) {
|
|
65
66
|
return function (editorState) {
|
|
66
67
|
// validate selection only when entering draft mode
|
|
67
|
-
if (drafting && (0, _utils.isSelectionValid)(editorState) !== _types2.AnnotationSelectionType.VALID) {
|
|
68
|
+
if (drafting && (0, _utils.isSelectionValid)(editorState, isCommentOnMediaOn) !== _types2.AnnotationSelectionType.VALID) {
|
|
68
69
|
return false;
|
|
69
70
|
}
|
|
70
71
|
return {
|
|
71
72
|
type: _types.ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE,
|
|
72
73
|
data: {
|
|
73
74
|
drafting: drafting,
|
|
74
|
-
editorState: editorState
|
|
75
|
+
editorState: editorState,
|
|
76
|
+
targetType: targetType
|
|
75
77
|
}
|
|
76
78
|
};
|
|
77
79
|
};
|
|
@@ -79,7 +81,9 @@ var getDraftCommandAction = function getDraftCommandAction(drafting) {
|
|
|
79
81
|
var setInlineCommentDraftState = exports.setInlineCommentDraftState = function setInlineCommentDraftState(editorAnalyticsAPI) {
|
|
80
82
|
return function (drafting) {
|
|
81
83
|
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
|
|
82
|
-
var
|
|
84
|
+
var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
|
|
85
|
+
var isCommentOnMediaOn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
86
|
+
var commandAction = getDraftCommandAction(drafting, targetType, isCommentOnMediaOn);
|
|
83
87
|
return (0, _pluginFactory.createCommand)(commandAction, _transform.default.addOpenCloseAnalytics(editorAnalyticsAPI)(drafting, inputMethod));
|
|
84
88
|
};
|
|
85
89
|
};
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -16,14 +16,17 @@ var _adfSchema = require("@atlaskit/adf-schema");
|
|
|
16
16
|
var _annotation = require("@atlaskit/editor-common/annotation");
|
|
17
17
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
18
18
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
|
+
var _commands = require("./commands");
|
|
19
20
|
var _inlineComment = require("./pm-plugins/inline-comment");
|
|
20
21
|
var _keymap = require("./pm-plugins/keymap");
|
|
21
22
|
var _toolbar = require("./toolbar");
|
|
22
23
|
var _InlineCommentView = require("./ui/InlineCommentView");
|
|
23
24
|
var _utils = require("./utils");
|
|
24
25
|
var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref) {
|
|
26
|
+
var _api$featureFlags, _api$analytics;
|
|
25
27
|
var annotationProviders = _ref.config,
|
|
26
28
|
api = _ref.api;
|
|
29
|
+
var featureFlags = api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState();
|
|
27
30
|
return {
|
|
28
31
|
name: 'annotation',
|
|
29
32
|
marks: function marks() {
|
|
@@ -33,7 +36,8 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
33
36
|
}];
|
|
34
37
|
},
|
|
35
38
|
actions: {
|
|
36
|
-
stripNonExistingAnnotations: _utils.stripNonExistingAnnotations
|
|
39
|
+
stripNonExistingAnnotations: _utils.stripNonExistingAnnotations,
|
|
40
|
+
setInlineCommentDraftState: (0, _commands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
37
41
|
},
|
|
38
42
|
getSharedState: function getSharedState(editorState) {
|
|
39
43
|
if (!editorState) {
|
|
@@ -49,13 +53,13 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
49
53
|
portalProviderAPI = _ref2.portalProviderAPI,
|
|
50
54
|
eventDispatcher = _ref2.eventDispatcher;
|
|
51
55
|
if (annotationProviders) {
|
|
52
|
-
var _api$
|
|
56
|
+
var _api$analytics2;
|
|
53
57
|
return (0, _inlineComment.inlineCommentPlugin)({
|
|
54
58
|
dispatch: dispatch,
|
|
55
59
|
portalProviderAPI: portalProviderAPI,
|
|
56
60
|
eventDispatcher: eventDispatcher,
|
|
57
61
|
provider: annotationProviders.inlineComment,
|
|
58
|
-
editorAnalyticsAPI: api === null || api === void 0 || (_api$
|
|
62
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions
|
|
59
63
|
});
|
|
60
64
|
}
|
|
61
65
|
return;
|
|
@@ -64,8 +68,8 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
64
68
|
name: 'annotationKeymap',
|
|
65
69
|
plugin: function plugin() {
|
|
66
70
|
if (annotationProviders) {
|
|
67
|
-
var _api$
|
|
68
|
-
return (0, _keymap.keymapPlugin)(api === null || api === void 0 || (_api$
|
|
71
|
+
var _api$analytics3;
|
|
72
|
+
return (0, _keymap.keymapPlugin)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
69
73
|
}
|
|
70
74
|
return;
|
|
71
75
|
}
|
|
@@ -78,9 +82,9 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
78
82
|
}
|
|
79
83
|
var pluginState = (0, _utils.getPluginState)(state);
|
|
80
84
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
81
|
-
var _api$
|
|
85
|
+
var _api$analytics4;
|
|
82
86
|
var isToolbarAbove = annotationProviders.inlineComment.isToolbarAbove;
|
|
83
|
-
return (0, _toolbar.buildToolbar)(api === null || api === void 0 || (_api$
|
|
87
|
+
return (0, _toolbar.buildToolbar)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(state, intl, isToolbarAbove, featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.commentsOnMedia);
|
|
84
88
|
}
|
|
85
89
|
},
|
|
86
90
|
selectionToolbar: function selectionToolbar(state, intl) {
|
|
@@ -89,9 +93,9 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
89
93
|
}
|
|
90
94
|
var pluginState = (0, _utils.getPluginState)(state);
|
|
91
95
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
92
|
-
var _api$
|
|
96
|
+
var _api$analytics5;
|
|
93
97
|
var isToolbarAbove = annotationProviders.inlineComment.isToolbarAbove;
|
|
94
|
-
return (0, _toolbar.buildToolbar)(api === null || api === void 0 || (_api$
|
|
98
|
+
return (0, _toolbar.buildToolbar)(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)(state, intl, isToolbarAbove, featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.commentsOnMedia);
|
|
95
99
|
}
|
|
96
100
|
}
|
|
97
101
|
},
|
|
@@ -111,7 +115,7 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
111
115
|
};
|
|
112
116
|
};
|
|
113
117
|
function AnnotationContentComponent(_ref4) {
|
|
114
|
-
var _api$
|
|
118
|
+
var _api$analytics6;
|
|
115
119
|
var api = _ref4.api,
|
|
116
120
|
editorView = _ref4.editorView,
|
|
117
121
|
annotationProviders = _ref4.annotationProviders,
|
|
@@ -127,7 +131,7 @@ function AnnotationContentComponent(_ref4) {
|
|
|
127
131
|
providers: annotationProviders,
|
|
128
132
|
editorView: editorView,
|
|
129
133
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
130
|
-
editorAnalyticsAPI: api === null || api === void 0 || (_api$
|
|
134
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions,
|
|
131
135
|
editorAPI: api
|
|
132
136
|
}));
|
|
133
137
|
}
|
|
@@ -24,7 +24,7 @@ var _default = exports.default = function _default(pluginState, action) {
|
|
|
24
24
|
mouseData: mouseData
|
|
25
25
|
});
|
|
26
26
|
case _types.ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
|
|
27
|
-
return getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
|
|
27
|
+
return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType);
|
|
28
28
|
case _types.ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
|
|
29
29
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
30
30
|
dirtyAnnotations: false,
|
|
@@ -59,7 +59,7 @@ var _default = exports.default = function _default(pluginState, action) {
|
|
|
59
59
|
return pluginState;
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
function getNewDraftState(pluginState, drafting, editorState) {
|
|
62
|
+
function getNewDraftState(pluginState, drafting, editorState, targetType) {
|
|
63
63
|
var draftDecorationSet = pluginState.draftDecorationSet;
|
|
64
64
|
if (!draftDecorationSet || !drafting) {
|
|
65
65
|
draftDecorationSet = _view.DecorationSet.empty;
|
|
@@ -71,7 +71,7 @@ function getNewDraftState(pluginState, drafting, editorState) {
|
|
|
71
71
|
if (drafting && editorState) {
|
|
72
72
|
newState.bookmark = editorState.selection.getBookmark();
|
|
73
73
|
var resolvedBookmark = newState.bookmark.resolve(editorState.doc);
|
|
74
|
-
var draftDecoration = (0, _utils.addDraftDecoration)(resolvedBookmark.from, resolvedBookmark.to);
|
|
74
|
+
var draftDecoration = (0, _utils.addDraftDecoration)(resolvedBookmark.from, resolvedBookmark.to, targetType);
|
|
75
75
|
newState.draftDecorationSet = draftDecorationSet.add(editorState.doc, [draftDecoration]);
|
|
76
76
|
}
|
|
77
77
|
return newState;
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.buildToolbar = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
10
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
11
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
11
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
14
|
var _comment = _interopRequireDefault(require("@atlaskit/icon/glyph/comment"));
|
|
@@ -17,9 +18,14 @@ var _utils2 = require("./utils");
|
|
|
17
18
|
var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsAPI) {
|
|
18
19
|
return function (state, intl) {
|
|
19
20
|
var isToolbarAbove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
21
|
+
var isCommentOnMediaOn = arguments.length > 3 ? arguments[3] : undefined;
|
|
22
|
+
var _supportedNodes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
20
23
|
var schema = state.schema;
|
|
21
|
-
var selectionValid = (0, _utils2.isSelectionValid)(state);
|
|
22
|
-
|
|
24
|
+
var selectionValid = (0, _utils2.isSelectionValid)(state, isCommentOnMediaOn);
|
|
25
|
+
var isMediaSelected = isCommentOnMediaOn && (0, _mediaSingle.currentMediaNodeWithPos)(state);
|
|
26
|
+
|
|
27
|
+
// comments on media can only be added via media floating toolbar
|
|
28
|
+
if (isMediaSelected || selectionValid === _types.AnnotationSelectionType.INVALID) {
|
|
23
29
|
return undefined;
|
|
24
30
|
}
|
|
25
31
|
var createCommentMessage = intl.formatMessage(_messages.annotationMessages.createComment);
|
package/dist/cjs/types.js
CHANGED
|
@@ -4,6 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.AnnotationTestIds = exports.AnnotationSelectionType = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* type of target that annotation apply to.
|
|
9
|
+
* This is used to apply correct decoration to a draft comment
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The source of draft comment being created
|
|
13
|
+
*/
|
|
7
14
|
var AnnotationSelectionType = exports.AnnotationSelectionType = /*#__PURE__*/function (AnnotationSelectionType) {
|
|
8
15
|
AnnotationSelectionType["INVALID"] = "invalid";
|
|
9
16
|
AnnotationSelectionType["DISABLED"] = "disabled";
|
|
@@ -137,7 +137,7 @@ function InlineCommentView(_ref) {
|
|
|
137
137
|
annotations: activeAnnotations,
|
|
138
138
|
dom: dom,
|
|
139
139
|
onDelete: function onDelete(id) {
|
|
140
|
-
return (0, _commands.removeInlineCommentNearSelection)(id)(state, dispatch);
|
|
140
|
+
return (0, _commands.removeInlineCommentNearSelection)(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch);
|
|
141
141
|
},
|
|
142
142
|
onResolve: function onResolve(id) {
|
|
143
143
|
return (0, _commands.updateInlineCommentResolvedState)(editorAnalyticsAPI)((0, _defineProperty2.default)({}, id, true), _analytics.RESOLVE_METHOD.COMPONENT)(editorView.state, editorView.dispatch);
|
package/dist/cjs/utils.js
CHANGED
|
@@ -28,6 +28,7 @@ exports.stripNonExistingAnnotations = stripNonExistingAnnotations;
|
|
|
28
28
|
exports.surroundingMarks = void 0;
|
|
29
29
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
30
30
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
31
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
31
32
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
32
33
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
33
34
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -130,6 +131,12 @@ var validateAnnotationMark = function validateAnnotationMark(annotationMark) {
|
|
|
130
131
|
* (when creating new comment)
|
|
131
132
|
*/
|
|
132
133
|
var addDraftDecoration = exports.addDraftDecoration = function addDraftDecoration(start, end) {
|
|
134
|
+
var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
|
|
135
|
+
if (targetType === 'block') {
|
|
136
|
+
return _view.Decoration.node(start, end, {
|
|
137
|
+
class: "".concat(_styles.AnnotationSharedClassNames.draft)
|
|
138
|
+
});
|
|
139
|
+
}
|
|
133
140
|
return _view.Decoration.inline(start, end, {
|
|
134
141
|
class: "".concat(_styles.AnnotationSharedClassNames.draft)
|
|
135
142
|
});
|
|
@@ -228,10 +235,17 @@ var getDraftCommandAnalyticsPayload = exports.getDraftCommandAnalyticsPayload =
|
|
|
228
235
|
};
|
|
229
236
|
return payload;
|
|
230
237
|
};
|
|
231
|
-
var isSelectionValid = exports.isSelectionValid = function isSelectionValid(state) {
|
|
238
|
+
var isSelectionValid = exports.isSelectionValid = function isSelectionValid(state, isCommentOnMediaOn) {
|
|
239
|
+
var _currentMediaNodeWith;
|
|
240
|
+
var _supportedNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
232
241
|
var selection = state.selection;
|
|
233
242
|
var _ref3 = getPluginState(state) || {},
|
|
234
243
|
disallowOnWhitespace = _ref3.disallowOnWhitespace;
|
|
244
|
+
|
|
245
|
+
// Allow media so that it can enter draft mode
|
|
246
|
+
if (isCommentOnMediaOn && (_currentMediaNodeWith = (0, _mediaSingle.currentMediaNodeWithPos)(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
|
|
247
|
+
return _types.AnnotationSelectionType.VALID;
|
|
248
|
+
}
|
|
235
249
|
if (selection.empty || !(selection instanceof _state.TextSelection || selection instanceof _state.AllSelection)) {
|
|
236
250
|
return _types.AnnotationSelectionType.INVALID;
|
|
237
251
|
}
|
|
@@ -22,7 +22,7 @@ export const closeComponent = () => createCommand({
|
|
|
22
22
|
export const clearDirtyMark = () => createCommand({
|
|
23
23
|
type: ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK
|
|
24
24
|
});
|
|
25
|
-
export const removeInlineCommentNearSelection = id => (state, dispatch) => {
|
|
25
|
+
export const removeInlineCommentNearSelection = (id, _supportedNodes = []) => (state, dispatch) => {
|
|
26
26
|
const {
|
|
27
27
|
tr,
|
|
28
28
|
selection: {
|
|
@@ -47,23 +47,24 @@ export const removeInlineCommentNearSelection = id => (state, dispatch) => {
|
|
|
47
47
|
}
|
|
48
48
|
return true;
|
|
49
49
|
};
|
|
50
|
-
const getDraftCommandAction = drafting => {
|
|
50
|
+
const getDraftCommandAction = (drafting, targetType, isCommentOnMediaOn) => {
|
|
51
51
|
return editorState => {
|
|
52
52
|
// validate selection only when entering draft mode
|
|
53
|
-
if (drafting && isSelectionValid(editorState) !== AnnotationSelectionType.VALID) {
|
|
53
|
+
if (drafting && isSelectionValid(editorState, isCommentOnMediaOn) !== AnnotationSelectionType.VALID) {
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
56
|
return {
|
|
57
57
|
type: ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE,
|
|
58
58
|
data: {
|
|
59
59
|
drafting,
|
|
60
|
-
editorState
|
|
60
|
+
editorState,
|
|
61
|
+
targetType
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
64
|
};
|
|
64
65
|
};
|
|
65
|
-
export const setInlineCommentDraftState = editorAnalyticsAPI => (drafting, inputMethod = INPUT_METHOD.TOOLBAR) => {
|
|
66
|
-
const commandAction = getDraftCommandAction(drafting);
|
|
66
|
+
export const setInlineCommentDraftState = editorAnalyticsAPI => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', isCommentOnMediaOn = false) => {
|
|
67
|
+
const commandAction = getDraftCommandAction(drafting, targetType, isCommentOnMediaOn);
|
|
67
68
|
return createCommand(commandAction, transform.addOpenCloseAnalytics(editorAnalyticsAPI)(drafting, inputMethod));
|
|
68
69
|
};
|
|
69
70
|
export const addInlineComment = (editorAnalyticsAPI, editorAPI) => id => {
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -3,6 +3,7 @@ import { annotation } from '@atlaskit/adf-schema';
|
|
|
3
3
|
import { AnnotationUpdateEmitter } from '@atlaskit/editor-common/annotation';
|
|
4
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { setInlineCommentDraftState } from './commands';
|
|
6
7
|
import { inlineCommentPlugin } from './pm-plugins/inline-comment';
|
|
7
8
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
8
9
|
import { buildToolbar } from './toolbar';
|
|
@@ -12,6 +13,8 @@ export const annotationPlugin = ({
|
|
|
12
13
|
config: annotationProviders,
|
|
13
14
|
api
|
|
14
15
|
}) => {
|
|
16
|
+
var _api$featureFlags, _api$analytics;
|
|
17
|
+
const featureFlags = api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState();
|
|
15
18
|
return {
|
|
16
19
|
name: 'annotation',
|
|
17
20
|
marks() {
|
|
@@ -21,7 +24,8 @@ export const annotationPlugin = ({
|
|
|
21
24
|
}];
|
|
22
25
|
},
|
|
23
26
|
actions: {
|
|
24
|
-
stripNonExistingAnnotations
|
|
27
|
+
stripNonExistingAnnotations,
|
|
28
|
+
setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
25
29
|
},
|
|
26
30
|
getSharedState(editorState) {
|
|
27
31
|
if (!editorState) {
|
|
@@ -37,13 +41,13 @@ export const annotationPlugin = ({
|
|
|
37
41
|
eventDispatcher
|
|
38
42
|
}) => {
|
|
39
43
|
if (annotationProviders) {
|
|
40
|
-
var _api$
|
|
44
|
+
var _api$analytics2;
|
|
41
45
|
return inlineCommentPlugin({
|
|
42
46
|
dispatch,
|
|
43
47
|
portalProviderAPI,
|
|
44
48
|
eventDispatcher,
|
|
45
49
|
provider: annotationProviders.inlineComment,
|
|
46
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$
|
|
50
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions
|
|
47
51
|
});
|
|
48
52
|
}
|
|
49
53
|
return;
|
|
@@ -52,8 +56,8 @@ export const annotationPlugin = ({
|
|
|
52
56
|
name: 'annotationKeymap',
|
|
53
57
|
plugin: () => {
|
|
54
58
|
if (annotationProviders) {
|
|
55
|
-
var _api$
|
|
56
|
-
return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$
|
|
59
|
+
var _api$analytics3;
|
|
60
|
+
return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
57
61
|
}
|
|
58
62
|
return;
|
|
59
63
|
}
|
|
@@ -65,11 +69,11 @@ export const annotationPlugin = ({
|
|
|
65
69
|
}
|
|
66
70
|
const pluginState = getPluginState(state);
|
|
67
71
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
68
|
-
var _api$
|
|
72
|
+
var _api$analytics4;
|
|
69
73
|
const {
|
|
70
74
|
isToolbarAbove
|
|
71
75
|
} = annotationProviders.inlineComment;
|
|
72
|
-
return buildToolbar(api === null || api === void 0 ? void 0 : (_api$
|
|
76
|
+
return buildToolbar(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(state, intl, isToolbarAbove, featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.commentsOnMedia);
|
|
73
77
|
}
|
|
74
78
|
},
|
|
75
79
|
selectionToolbar(state, intl) {
|
|
@@ -78,11 +82,11 @@ export const annotationPlugin = ({
|
|
|
78
82
|
}
|
|
79
83
|
const pluginState = getPluginState(state);
|
|
80
84
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
81
|
-
var _api$
|
|
85
|
+
var _api$analytics5;
|
|
82
86
|
const {
|
|
83
87
|
isToolbarAbove
|
|
84
88
|
} = annotationProviders.inlineComment;
|
|
85
|
-
return buildToolbar(api === null || api === void 0 ? void 0 : (_api$
|
|
89
|
+
return buildToolbar(api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)(state, intl, isToolbarAbove, featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.commentsOnMedia);
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
},
|
|
@@ -108,7 +112,7 @@ function AnnotationContentComponent({
|
|
|
108
112
|
annotationProviders,
|
|
109
113
|
dispatchAnalyticsEvent
|
|
110
114
|
}) {
|
|
111
|
-
var _api$
|
|
115
|
+
var _api$analytics6;
|
|
112
116
|
const {
|
|
113
117
|
annotationState: inlineCommentState
|
|
114
118
|
} = useSharedPluginState(api, ['annotation']);
|
|
@@ -121,7 +125,7 @@ function AnnotationContentComponent({
|
|
|
121
125
|
providers: annotationProviders,
|
|
122
126
|
editorView: editorView,
|
|
123
127
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
124
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$
|
|
128
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions,
|
|
125
129
|
editorAPI: api
|
|
126
130
|
}));
|
|
127
131
|
}
|
|
@@ -18,7 +18,7 @@ export default ((pluginState, action) => {
|
|
|
18
18
|
mouseData
|
|
19
19
|
};
|
|
20
20
|
case ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
|
|
21
|
-
return getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
|
|
21
|
+
return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType);
|
|
22
22
|
case ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
|
|
23
23
|
return {
|
|
24
24
|
...pluginState,
|
|
@@ -63,7 +63,7 @@ export default ((pluginState, action) => {
|
|
|
63
63
|
return pluginState;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
-
function getNewDraftState(pluginState, drafting, editorState) {
|
|
66
|
+
function getNewDraftState(pluginState, drafting, editorState, targetType) {
|
|
67
67
|
let {
|
|
68
68
|
draftDecorationSet
|
|
69
69
|
} = pluginState;
|
|
@@ -78,7 +78,7 @@ function getNewDraftState(pluginState, drafting, editorState) {
|
|
|
78
78
|
if (drafting && editorState) {
|
|
79
79
|
newState.bookmark = editorState.selection.getBookmark();
|
|
80
80
|
const resolvedBookmark = newState.bookmark.resolve(editorState.doc);
|
|
81
|
-
const draftDecoration = addDraftDecoration(resolvedBookmark.from, resolvedBookmark.to);
|
|
81
|
+
const draftDecoration = addDraftDecoration(resolvedBookmark.from, resolvedBookmark.to, targetType);
|
|
82
82
|
newState.draftDecorationSet = draftDecorationSet.add(editorState.doc, [draftDecoration]);
|
|
83
83
|
}
|
|
84
84
|
return newState;
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { addInlineComment, ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
4
|
+
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
4
5
|
import { annotationMessages } from '@atlaskit/editor-common/messages';
|
|
5
6
|
import { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
|
|
6
7
|
import CommentIcon from '@atlaskit/icon/glyph/comment';
|
|
7
8
|
import { setInlineCommentDraftState } from './commands';
|
|
8
9
|
import { AnnotationSelectionType, AnnotationTestIds } from './types';
|
|
9
10
|
import { isSelectionValid } from './utils';
|
|
10
|
-
export const buildToolbar = editorAnalyticsAPI => (state, intl, isToolbarAbove = false) => {
|
|
11
|
+
export const buildToolbar = editorAnalyticsAPI => (state, intl, isToolbarAbove = false, isCommentOnMediaOn, _supportedNodes = []) => {
|
|
11
12
|
const {
|
|
12
13
|
schema
|
|
13
14
|
} = state;
|
|
14
|
-
const selectionValid = isSelectionValid(state);
|
|
15
|
-
|
|
15
|
+
const selectionValid = isSelectionValid(state, isCommentOnMediaOn);
|
|
16
|
+
const isMediaSelected = isCommentOnMediaOn && currentMediaNodeWithPos(state);
|
|
17
|
+
|
|
18
|
+
// comments on media can only be added via media floating toolbar
|
|
19
|
+
if (isMediaSelected || selectionValid === AnnotationSelectionType.INVALID) {
|
|
16
20
|
return undefined;
|
|
17
21
|
}
|
|
18
22
|
const createCommentMessage = intl.formatMessage(annotationMessages.createComment);
|
package/dist/es2019/types.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* type of target that annotation apply to.
|
|
3
|
+
* This is used to apply correct decoration to a draft comment
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The source of draft comment being created
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
export let AnnotationSelectionType = /*#__PURE__*/function (AnnotationSelectionType) {
|
|
2
11
|
AnnotationSelectionType["INVALID"] = "invalid";
|
|
3
12
|
AnnotationSelectionType["DISABLED"] = "disabled";
|
|
@@ -134,7 +134,7 @@ export function InlineCommentView({
|
|
|
134
134
|
annotationsList: annotationsList,
|
|
135
135
|
annotations: activeAnnotations,
|
|
136
136
|
dom: dom,
|
|
137
|
-
onDelete: id => removeInlineCommentNearSelection(id)(state, dispatch),
|
|
137
|
+
onDelete: id => removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch),
|
|
138
138
|
onResolve: id => updateInlineCommentResolvedState(editorAnalyticsAPI)({
|
|
139
139
|
[id]: true
|
|
140
140
|
}, RESOLVE_METHOD.COMPONENT)(editorView.state, editorView.dispatch),
|
package/dist/es2019/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
3
4
|
import { AnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
|
|
4
5
|
import { canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, hasAnnotationMark, isParagraph, isText } from '@atlaskit/editor-common/utils';
|
|
5
6
|
import { AllSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -91,7 +92,12 @@ const validateAnnotationMark = annotationMark => {
|
|
|
91
92
|
* add decoration for the comment selection in draft state
|
|
92
93
|
* (when creating new comment)
|
|
93
94
|
*/
|
|
94
|
-
export const addDraftDecoration = (start, end) => {
|
|
95
|
+
export const addDraftDecoration = (start, end, targetType = 'inline') => {
|
|
96
|
+
if (targetType === 'block') {
|
|
97
|
+
return Decoration.node(start, end, {
|
|
98
|
+
class: `${AnnotationSharedClassNames.draft}`
|
|
99
|
+
});
|
|
100
|
+
}
|
|
95
101
|
return Decoration.inline(start, end, {
|
|
96
102
|
class: `${AnnotationSharedClassNames.draft}`
|
|
97
103
|
});
|
|
@@ -188,13 +194,19 @@ export const getDraftCommandAnalyticsPayload = (drafting, inputMethod) => {
|
|
|
188
194
|
};
|
|
189
195
|
return payload;
|
|
190
196
|
};
|
|
191
|
-
export const isSelectionValid = state => {
|
|
197
|
+
export const isSelectionValid = (state, isCommentOnMediaOn, _supportedNodes = []) => {
|
|
198
|
+
var _currentMediaNodeWith;
|
|
192
199
|
const {
|
|
193
200
|
selection
|
|
194
201
|
} = state;
|
|
195
202
|
const {
|
|
196
203
|
disallowOnWhitespace
|
|
197
204
|
} = getPluginState(state) || {};
|
|
205
|
+
|
|
206
|
+
// Allow media so that it can enter draft mode
|
|
207
|
+
if (isCommentOnMediaOn && (_currentMediaNodeWith = currentMediaNodeWithPos(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
|
|
208
|
+
return AnnotationSelectionType.VALID;
|
|
209
|
+
}
|
|
198
210
|
if (selection.empty || !(selection instanceof TextSelection || selection instanceof AllSelection)) {
|
|
199
211
|
return AnnotationSelectionType.INVALID;
|
|
200
212
|
}
|
|
@@ -32,6 +32,7 @@ export var clearDirtyMark = function clearDirtyMark() {
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
export var removeInlineCommentNearSelection = function removeInlineCommentNearSelection(id) {
|
|
35
|
+
var _supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
35
36
|
return function (state, dispatch) {
|
|
36
37
|
var tr = state.tr,
|
|
37
38
|
$from = state.selection.$from;
|
|
@@ -54,17 +55,18 @@ export var removeInlineCommentNearSelection = function removeInlineCommentNearSe
|
|
|
54
55
|
return true;
|
|
55
56
|
};
|
|
56
57
|
};
|
|
57
|
-
var getDraftCommandAction = function getDraftCommandAction(drafting) {
|
|
58
|
+
var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, isCommentOnMediaOn) {
|
|
58
59
|
return function (editorState) {
|
|
59
60
|
// validate selection only when entering draft mode
|
|
60
|
-
if (drafting && isSelectionValid(editorState) !== AnnotationSelectionType.VALID) {
|
|
61
|
+
if (drafting && isSelectionValid(editorState, isCommentOnMediaOn) !== AnnotationSelectionType.VALID) {
|
|
61
62
|
return false;
|
|
62
63
|
}
|
|
63
64
|
return {
|
|
64
65
|
type: ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE,
|
|
65
66
|
data: {
|
|
66
67
|
drafting: drafting,
|
|
67
|
-
editorState: editorState
|
|
68
|
+
editorState: editorState,
|
|
69
|
+
targetType: targetType
|
|
68
70
|
}
|
|
69
71
|
};
|
|
70
72
|
};
|
|
@@ -72,7 +74,9 @@ var getDraftCommandAction = function getDraftCommandAction(drafting) {
|
|
|
72
74
|
export var setInlineCommentDraftState = function setInlineCommentDraftState(editorAnalyticsAPI) {
|
|
73
75
|
return function (drafting) {
|
|
74
76
|
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
|
|
75
|
-
var
|
|
77
|
+
var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
|
|
78
|
+
var isCommentOnMediaOn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
79
|
+
var commandAction = getDraftCommandAction(drafting, targetType, isCommentOnMediaOn);
|
|
76
80
|
return createCommand(commandAction, transform.addOpenCloseAnalytics(editorAnalyticsAPI)(drafting, inputMethod));
|
|
77
81
|
};
|
|
78
82
|
};
|
package/dist/esm/plugin.js
CHANGED
|
@@ -3,14 +3,17 @@ import { annotation } from '@atlaskit/adf-schema';
|
|
|
3
3
|
import { AnnotationUpdateEmitter } from '@atlaskit/editor-common/annotation';
|
|
4
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { setInlineCommentDraftState } from './commands';
|
|
6
7
|
import { inlineCommentPlugin } from './pm-plugins/inline-comment';
|
|
7
8
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
8
9
|
import { buildToolbar } from './toolbar';
|
|
9
10
|
import { InlineCommentView } from './ui/InlineCommentView';
|
|
10
11
|
import { getPluginState, stripNonExistingAnnotations } from './utils';
|
|
11
12
|
export var annotationPlugin = function annotationPlugin(_ref) {
|
|
13
|
+
var _api$featureFlags, _api$analytics;
|
|
12
14
|
var annotationProviders = _ref.config,
|
|
13
15
|
api = _ref.api;
|
|
16
|
+
var featureFlags = api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState();
|
|
14
17
|
return {
|
|
15
18
|
name: 'annotation',
|
|
16
19
|
marks: function marks() {
|
|
@@ -20,7 +23,8 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
20
23
|
}];
|
|
21
24
|
},
|
|
22
25
|
actions: {
|
|
23
|
-
stripNonExistingAnnotations: stripNonExistingAnnotations
|
|
26
|
+
stripNonExistingAnnotations: stripNonExistingAnnotations,
|
|
27
|
+
setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
24
28
|
},
|
|
25
29
|
getSharedState: function getSharedState(editorState) {
|
|
26
30
|
if (!editorState) {
|
|
@@ -36,13 +40,13 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
36
40
|
portalProviderAPI = _ref2.portalProviderAPI,
|
|
37
41
|
eventDispatcher = _ref2.eventDispatcher;
|
|
38
42
|
if (annotationProviders) {
|
|
39
|
-
var _api$
|
|
43
|
+
var _api$analytics2;
|
|
40
44
|
return inlineCommentPlugin({
|
|
41
45
|
dispatch: dispatch,
|
|
42
46
|
portalProviderAPI: portalProviderAPI,
|
|
43
47
|
eventDispatcher: eventDispatcher,
|
|
44
48
|
provider: annotationProviders.inlineComment,
|
|
45
|
-
editorAnalyticsAPI: api === null || api === void 0 || (_api$
|
|
49
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions
|
|
46
50
|
});
|
|
47
51
|
}
|
|
48
52
|
return;
|
|
@@ -51,8 +55,8 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
51
55
|
name: 'annotationKeymap',
|
|
52
56
|
plugin: function plugin() {
|
|
53
57
|
if (annotationProviders) {
|
|
54
|
-
var _api$
|
|
55
|
-
return keymapPlugin(api === null || api === void 0 || (_api$
|
|
58
|
+
var _api$analytics3;
|
|
59
|
+
return keymapPlugin(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
56
60
|
}
|
|
57
61
|
return;
|
|
58
62
|
}
|
|
@@ -65,9 +69,9 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
65
69
|
}
|
|
66
70
|
var pluginState = getPluginState(state);
|
|
67
71
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
68
|
-
var _api$
|
|
72
|
+
var _api$analytics4;
|
|
69
73
|
var isToolbarAbove = annotationProviders.inlineComment.isToolbarAbove;
|
|
70
|
-
return buildToolbar(api === null || api === void 0 || (_api$
|
|
74
|
+
return buildToolbar(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(state, intl, isToolbarAbove, featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.commentsOnMedia);
|
|
71
75
|
}
|
|
72
76
|
},
|
|
73
77
|
selectionToolbar: function selectionToolbar(state, intl) {
|
|
@@ -76,9 +80,9 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
76
80
|
}
|
|
77
81
|
var pluginState = getPluginState(state);
|
|
78
82
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
79
|
-
var _api$
|
|
83
|
+
var _api$analytics5;
|
|
80
84
|
var isToolbarAbove = annotationProviders.inlineComment.isToolbarAbove;
|
|
81
|
-
return buildToolbar(api === null || api === void 0 || (_api$
|
|
85
|
+
return buildToolbar(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)(state, intl, isToolbarAbove, featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.commentsOnMedia);
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
},
|
|
@@ -98,7 +102,7 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
98
102
|
};
|
|
99
103
|
};
|
|
100
104
|
function AnnotationContentComponent(_ref4) {
|
|
101
|
-
var _api$
|
|
105
|
+
var _api$analytics6;
|
|
102
106
|
var api = _ref4.api,
|
|
103
107
|
editorView = _ref4.editorView,
|
|
104
108
|
annotationProviders = _ref4.annotationProviders,
|
|
@@ -114,7 +118,7 @@ function AnnotationContentComponent(_ref4) {
|
|
|
114
118
|
providers: annotationProviders,
|
|
115
119
|
editorView: editorView,
|
|
116
120
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
117
|
-
editorAnalyticsAPI: api === null || api === void 0 || (_api$
|
|
121
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions,
|
|
118
122
|
editorAPI: api
|
|
119
123
|
}));
|
|
120
124
|
}
|
|
@@ -17,7 +17,7 @@ export default (function (pluginState, action) {
|
|
|
17
17
|
mouseData: mouseData
|
|
18
18
|
});
|
|
19
19
|
case ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
|
|
20
|
-
return getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
|
|
20
|
+
return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType);
|
|
21
21
|
case ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
|
|
22
22
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
23
23
|
dirtyAnnotations: false,
|
|
@@ -52,7 +52,7 @@ export default (function (pluginState, action) {
|
|
|
52
52
|
return pluginState;
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
-
function getNewDraftState(pluginState, drafting, editorState) {
|
|
55
|
+
function getNewDraftState(pluginState, drafting, editorState, targetType) {
|
|
56
56
|
var draftDecorationSet = pluginState.draftDecorationSet;
|
|
57
57
|
if (!draftDecorationSet || !drafting) {
|
|
58
58
|
draftDecorationSet = DecorationSet.empty;
|
|
@@ -64,7 +64,7 @@ function getNewDraftState(pluginState, drafting, editorState) {
|
|
|
64
64
|
if (drafting && editorState) {
|
|
65
65
|
newState.bookmark = editorState.selection.getBookmark();
|
|
66
66
|
var resolvedBookmark = newState.bookmark.resolve(editorState.doc);
|
|
67
|
-
var draftDecoration = addDraftDecoration(resolvedBookmark.from, resolvedBookmark.to);
|
|
67
|
+
var draftDecoration = addDraftDecoration(resolvedBookmark.from, resolvedBookmark.to, targetType);
|
|
68
68
|
newState.draftDecorationSet = draftDecorationSet.add(editorState.doc, [draftDecoration]);
|
|
69
69
|
}
|
|
70
70
|
return newState;
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { addInlineComment, ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
4
|
+
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
4
5
|
import { annotationMessages } from '@atlaskit/editor-common/messages';
|
|
5
6
|
import { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
|
|
6
7
|
import CommentIcon from '@atlaskit/icon/glyph/comment';
|
|
@@ -10,9 +11,14 @@ import { isSelectionValid } from './utils';
|
|
|
10
11
|
export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
|
|
11
12
|
return function (state, intl) {
|
|
12
13
|
var isToolbarAbove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
14
|
+
var isCommentOnMediaOn = arguments.length > 3 ? arguments[3] : undefined;
|
|
15
|
+
var _supportedNodes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
13
16
|
var schema = state.schema;
|
|
14
|
-
var selectionValid = isSelectionValid(state);
|
|
15
|
-
|
|
17
|
+
var selectionValid = isSelectionValid(state, isCommentOnMediaOn);
|
|
18
|
+
var isMediaSelected = isCommentOnMediaOn && currentMediaNodeWithPos(state);
|
|
19
|
+
|
|
20
|
+
// comments on media can only be added via media floating toolbar
|
|
21
|
+
if (isMediaSelected || selectionValid === AnnotationSelectionType.INVALID) {
|
|
16
22
|
return undefined;
|
|
17
23
|
}
|
|
18
24
|
var createCommentMessage = intl.formatMessage(annotationMessages.createComment);
|
package/dist/esm/types.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* type of target that annotation apply to.
|
|
3
|
+
* This is used to apply correct decoration to a draft comment
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The source of draft comment being created
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
export var AnnotationSelectionType = /*#__PURE__*/function (AnnotationSelectionType) {
|
|
2
11
|
AnnotationSelectionType["INVALID"] = "invalid";
|
|
3
12
|
AnnotationSelectionType["DISABLED"] = "disabled";
|
|
@@ -130,7 +130,7 @@ export function InlineCommentView(_ref) {
|
|
|
130
130
|
annotations: activeAnnotations,
|
|
131
131
|
dom: dom,
|
|
132
132
|
onDelete: function onDelete(id) {
|
|
133
|
-
return removeInlineCommentNearSelection(id)(state, dispatch);
|
|
133
|
+
return removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch);
|
|
134
134
|
},
|
|
135
135
|
onResolve: function onResolve(id) {
|
|
136
136
|
return updateInlineCommentResolvedState(editorAnalyticsAPI)(_defineProperty({}, id, true), RESOLVE_METHOD.COMPONENT)(editorView.state, editorView.dispatch);
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
3
4
|
import { AnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
|
|
4
5
|
import { canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, hasAnnotationMark, isParagraph, isText } from '@atlaskit/editor-common/utils';
|
|
5
6
|
import { AllSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -103,6 +104,12 @@ var validateAnnotationMark = function validateAnnotationMark(annotationMark) {
|
|
|
103
104
|
* (when creating new comment)
|
|
104
105
|
*/
|
|
105
106
|
export var addDraftDecoration = function addDraftDecoration(start, end) {
|
|
107
|
+
var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
|
|
108
|
+
if (targetType === 'block') {
|
|
109
|
+
return Decoration.node(start, end, {
|
|
110
|
+
class: "".concat(AnnotationSharedClassNames.draft)
|
|
111
|
+
});
|
|
112
|
+
}
|
|
106
113
|
return Decoration.inline(start, end, {
|
|
107
114
|
class: "".concat(AnnotationSharedClassNames.draft)
|
|
108
115
|
});
|
|
@@ -201,10 +208,17 @@ export var getDraftCommandAnalyticsPayload = function getDraftCommandAnalyticsPa
|
|
|
201
208
|
};
|
|
202
209
|
return payload;
|
|
203
210
|
};
|
|
204
|
-
export var isSelectionValid = function isSelectionValid(state) {
|
|
211
|
+
export var isSelectionValid = function isSelectionValid(state, isCommentOnMediaOn) {
|
|
212
|
+
var _currentMediaNodeWith;
|
|
213
|
+
var _supportedNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
205
214
|
var selection = state.selection;
|
|
206
215
|
var _ref3 = getPluginState(state) || {},
|
|
207
216
|
disallowOnWhitespace = _ref3.disallowOnWhitespace;
|
|
217
|
+
|
|
218
|
+
// Allow media so that it can enter draft mode
|
|
219
|
+
if (isCommentOnMediaOn && (_currentMediaNodeWith = currentMediaNodeWithPos(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
|
|
220
|
+
return AnnotationSelectionType.VALID;
|
|
221
|
+
}
|
|
208
222
|
if (selection.empty || !(selection instanceof TextSelection || selection instanceof AllSelection)) {
|
|
209
223
|
return AnnotationSelectionType.INVALID;
|
|
210
224
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { EditorAnalyticsAPI, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
4
|
import type { InlineCommentMap, InlineCommentMouseData } from '../pm-plugins/types';
|
|
6
|
-
import type { AnnotationPlugin } from '../types';
|
|
5
|
+
import type { AnnotationPlugin, InlineCommentInputMethod, TargetType } from '../types';
|
|
7
6
|
export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
|
|
8
7
|
export declare const closeComponent: () => Command;
|
|
9
8
|
export declare const clearDirtyMark: () => Command;
|
|
10
|
-
export declare const removeInlineCommentNearSelection: (id: string) => Command;
|
|
11
|
-
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, inputMethod?:
|
|
9
|
+
export declare const removeInlineCommentNearSelection: (id: string, _supportedNodes?: string[]) => Command;
|
|
10
|
+
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
|
|
12
11
|
export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string) => Command;
|
|
13
12
|
export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
|
|
14
13
|
export declare const setSelectedAnnotation: (id: string) => Command;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
1
|
import type { EditorAnalyticsAPI, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
2
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { InlineCommentInputMethod } from '../types';
|
|
4
4
|
declare const _default: {
|
|
5
5
|
addAnnotationMark: (id: string) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
6
6
|
addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI: import("@atlaskit/editor-common/types").PublicPluginAPI<[import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"annotation", {
|
|
@@ -62,9 +62,13 @@ declare const _default: {
|
|
|
62
62
|
};
|
|
63
63
|
}, {
|
|
64
64
|
mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
|
|
65
|
-
} | undefined
|
|
65
|
+
} | undefined>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
66
|
+
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
67
|
+
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
68
|
+
}, import("@atlaskit/editor-common/types").FeatureFlags>>];
|
|
66
69
|
actions: {
|
|
67
70
|
stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
|
|
71
|
+
setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
68
72
|
};
|
|
69
73
|
}, import("../types").AnnotationProviders | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
|
|
70
74
|
pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
|
|
@@ -122,8 +126,11 @@ declare const _default: {
|
|
|
122
126
|
};
|
|
123
127
|
}, {
|
|
124
128
|
mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
|
|
125
|
-
} | undefined
|
|
126
|
-
|
|
129
|
+
} | undefined>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
130
|
+
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
131
|
+
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
132
|
+
}, import("@atlaskit/editor-common/types").FeatureFlags>>]> | undefined) => (id: string) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
133
|
+
addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
127
134
|
addInsertAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
128
135
|
addResolveAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (method?: RESOLVE_METHOD | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
129
136
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { annotationPlugin } from './plugin';
|
|
2
|
-
export type { AnnotationPlugin, AnnotationProviders, InlineCommentAnnotationProvider, AnnotationInfo, InlineCommentCreateComponentProps, InlineCommentViewComponentProps, AnnotationState, AnnotationTypeProvider, InlineCommentState, } from './types';
|
|
2
|
+
export type { AnnotationPlugin, AnnotationProviders, InlineCommentAnnotationProvider, AnnotationInfo, InlineCommentCreateComponentProps, InlineCommentViewComponentProps, AnnotationState, AnnotationTypeProvider, InlineCommentState, TargetType, InlineCommentInputMethod, } from './types';
|
|
3
3
|
export type { InlineCommentMap, InlineCommentPluginState, InlineCommentPluginOptions, InlineCommentAction, } from './pm-plugins/types';
|
|
@@ -3,7 +3,7 @@ import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-di
|
|
|
3
3
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
4
4
|
import type { EditorState, SelectionBookmark } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import type { AnnotationInfo, InlineCommentAnnotationProvider } from '../types';
|
|
6
|
+
import type { AnnotationInfo, InlineCommentAnnotationProvider, TargetType } from '../types';
|
|
7
7
|
export declare enum ACTIONS {
|
|
8
8
|
UPDATE_INLINE_COMMENT_STATE = 0,
|
|
9
9
|
SET_INLINE_COMMENT_DRAFT_STATE = 1,
|
|
@@ -35,6 +35,7 @@ export type InlineCommentAction = {
|
|
|
35
35
|
data: {
|
|
36
36
|
drafting: boolean;
|
|
37
37
|
editorState: EditorState;
|
|
38
|
+
targetType?: TargetType;
|
|
38
39
|
};
|
|
39
40
|
} | {
|
|
40
41
|
type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
|
package/dist/types/toolbar.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import type { IntlShape } from 'react-intl-next';
|
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { FloatingToolbarConfig } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (state: EditorState, intl: IntlShape, isToolbarAbove?: boolean) => FloatingToolbarConfig | undefined;
|
|
5
|
+
export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (state: EditorState, intl: IntlShape, isToolbarAbove?: boolean, isCommentOnMediaOn?: boolean, _supportedNodes?: string[]) => FloatingToolbarConfig | undefined;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,22 +1,40 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import type { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
3
|
+
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import type { AnnotationUpdateEmitter } from '@atlaskit/editor-common/annotation';
|
|
4
|
-
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
5
6
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
6
7
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
8
|
+
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
7
9
|
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
8
10
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
9
11
|
import type { InlineCommentPluginState } from './pm-plugins/types';
|
|
10
12
|
type StripNonExistingAnnotations = (slice: Slice, state: EditorState) => boolean | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* type of target that annotation apply to.
|
|
15
|
+
* This is used to apply correct decoration to a draft comment
|
|
16
|
+
*/
|
|
17
|
+
export type TargetType = 'block' | 'inline';
|
|
18
|
+
/**
|
|
19
|
+
* The source of draft comment being created
|
|
20
|
+
*/
|
|
21
|
+
export type InlineCommentInputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB;
|
|
22
|
+
type SetInlineCommentDraftState = (drafting: boolean, inputMethod: InlineCommentInputMethod,
|
|
23
|
+
/** @default 'inline' */
|
|
24
|
+
targetType?: TargetType,
|
|
25
|
+
/** check for platform_editor_media_comments_base feature gate */
|
|
26
|
+
isCommentOnMediaOn?: boolean) => Command;
|
|
11
27
|
export type AnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
12
28
|
pluginConfiguration: AnnotationProviders | undefined;
|
|
13
29
|
sharedState: InlineCommentPluginState | undefined;
|
|
14
30
|
dependencies: [
|
|
15
31
|
OptionalPlugin<AnalyticsPlugin>,
|
|
16
|
-
OptionalPlugin<EditorViewModePlugin
|
|
32
|
+
OptionalPlugin<EditorViewModePlugin>,
|
|
33
|
+
OptionalPlugin<FeatureFlagsPlugin>
|
|
17
34
|
];
|
|
18
35
|
actions: {
|
|
19
36
|
stripNonExistingAnnotations: StripNonExistingAnnotations;
|
|
37
|
+
setInlineCommentDraftState: SetInlineCommentDraftState;
|
|
20
38
|
};
|
|
21
39
|
}>;
|
|
22
40
|
export type AnnotationInfo = {
|
|
@@ -79,6 +97,16 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
|
|
|
79
97
|
createComponent?: React.ComponentType<InlineCommentCreateComponentProps>;
|
|
80
98
|
viewComponent?: React.ComponentType<InlineCommentViewComponentProps>;
|
|
81
99
|
isToolbarAbove?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* @experimental Still under development. Do not use.
|
|
102
|
+
*
|
|
103
|
+
* A list of supported editor node names for inline comment,
|
|
104
|
+
* Note 1: value is the type name of the node, e.g. media, mediaInline
|
|
105
|
+
* Invalid node names, nodes does not support annotation
|
|
106
|
+
* or nodes not supported by current ADF schema will be ignored.
|
|
107
|
+
* Note 2: text is supported by default.
|
|
108
|
+
*/
|
|
109
|
+
supportedBlockNodes?: string[];
|
|
82
110
|
};
|
|
83
111
|
export interface AnnotationProviders {
|
|
84
112
|
inlineComment: InlineCommentAnnotationProvider;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { AnalyticsEventPayloadCallback
|
|
1
|
+
import type { AnalyticsEventPayloadCallback } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { containsAnyAnnotations, hasAnnotationMark } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import type { Mark, Node, ResolvedPos, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { AllSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import type { InlineCommentPluginState } from './pm-plugins/types';
|
|
8
|
-
import type { AnnotationInfo } from './types';
|
|
8
|
+
import type { AnnotationInfo, InlineCommentInputMethod, TargetType } from './types';
|
|
9
9
|
import { AnnotationSelectionType } from './types';
|
|
10
10
|
export { hasAnnotationMark, containsAnyAnnotations };
|
|
11
11
|
/**
|
|
@@ -14,7 +14,7 @@ export { hasAnnotationMark, containsAnyAnnotations };
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const surroundingMarks: ($pos: ResolvedPos) => (readonly Mark[])[];
|
|
16
16
|
export declare const getAllAnnotations: (doc: Node) => string[];
|
|
17
|
-
export declare const addDraftDecoration: (start: number, end: number) => Decoration;
|
|
17
|
+
export declare const addDraftDecoration: (start: number, end: number, targetType?: TargetType) => Decoration;
|
|
18
18
|
export declare const getAnnotationViewKey: (annotations: AnnotationInfo[]) => string;
|
|
19
19
|
export declare const findAnnotationsInSelection: (selection: Selection, doc: Node) => AnnotationInfo[];
|
|
20
20
|
/**
|
|
@@ -27,8 +27,8 @@ export declare const getPluginState: (state: EditorState) => InlineCommentPlugin
|
|
|
27
27
|
/**
|
|
28
28
|
* get payload for the open/close analytics event
|
|
29
29
|
*/
|
|
30
|
-
export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod:
|
|
31
|
-
export declare const isSelectionValid: (state: EditorState) => AnnotationSelectionType;
|
|
30
|
+
export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: InlineCommentInputMethod) => AnalyticsEventPayloadCallback;
|
|
31
|
+
export declare const isSelectionValid: (state: EditorState, isCommentOnMediaOn?: boolean, _supportedNodes?: string[]) => AnnotationSelectionType;
|
|
32
32
|
export declare const hasInvalidNodes: (state: EditorState) => boolean;
|
|
33
33
|
/**
|
|
34
34
|
* Checks if any of the nodes in a given selection are completely whitespace
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { EditorAnalyticsAPI, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
4
|
import type { InlineCommentMap, InlineCommentMouseData } from '../pm-plugins/types';
|
|
6
|
-
import type { AnnotationPlugin } from '../types';
|
|
5
|
+
import type { AnnotationPlugin, InlineCommentInputMethod, TargetType } from '../types';
|
|
7
6
|
export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
|
|
8
7
|
export declare const closeComponent: () => Command;
|
|
9
8
|
export declare const clearDirtyMark: () => Command;
|
|
10
|
-
export declare const removeInlineCommentNearSelection: (id: string) => Command;
|
|
11
|
-
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, inputMethod?:
|
|
9
|
+
export declare const removeInlineCommentNearSelection: (id: string, _supportedNodes?: string[]) => Command;
|
|
10
|
+
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
|
|
12
11
|
export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string) => Command;
|
|
13
12
|
export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
|
|
14
13
|
export declare const setSelectedAnnotation: (id: string) => Command;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
1
|
import type { EditorAnalyticsAPI, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
2
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { InlineCommentInputMethod } from '../types';
|
|
4
4
|
declare const _default: {
|
|
5
5
|
addAnnotationMark: (id: string) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
6
6
|
addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI: import("@atlaskit/editor-common/types").PublicPluginAPI<[
|
|
@@ -74,10 +74,15 @@ declare const _default: {
|
|
|
74
74
|
};
|
|
75
75
|
}, {
|
|
76
76
|
mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
|
|
77
|
-
} | undefined
|
|
77
|
+
} | undefined>>,
|
|
78
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
79
|
+
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
80
|
+
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
81
|
+
}, import("@atlaskit/editor-common/types").FeatureFlags>>
|
|
78
82
|
];
|
|
79
83
|
actions: {
|
|
80
84
|
stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
|
|
85
|
+
setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
81
86
|
};
|
|
82
87
|
}, import("../types").AnnotationProviders | undefined>,
|
|
83
88
|
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
|
|
@@ -146,9 +151,13 @@ declare const _default: {
|
|
|
146
151
|
};
|
|
147
152
|
}, {
|
|
148
153
|
mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
|
|
149
|
-
} | undefined
|
|
154
|
+
} | undefined>>,
|
|
155
|
+
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
|
|
156
|
+
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
157
|
+
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
158
|
+
}, import("@atlaskit/editor-common/types").FeatureFlags>>
|
|
150
159
|
]> | undefined) => (id: string) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
151
|
-
addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?:
|
|
160
|
+
addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
152
161
|
addInsertAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
153
162
|
addResolveAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (method?: RESOLVE_METHOD | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
154
163
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { annotationPlugin } from './plugin';
|
|
2
|
-
export type { AnnotationPlugin, AnnotationProviders, InlineCommentAnnotationProvider, AnnotationInfo, InlineCommentCreateComponentProps, InlineCommentViewComponentProps, AnnotationState, AnnotationTypeProvider, InlineCommentState, } from './types';
|
|
2
|
+
export type { AnnotationPlugin, AnnotationProviders, InlineCommentAnnotationProvider, AnnotationInfo, InlineCommentCreateComponentProps, InlineCommentViewComponentProps, AnnotationState, AnnotationTypeProvider, InlineCommentState, TargetType, InlineCommentInputMethod, } from './types';
|
|
3
3
|
export type { InlineCommentMap, InlineCommentPluginState, InlineCommentPluginOptions, InlineCommentAction, } from './pm-plugins/types';
|
|
@@ -3,7 +3,7 @@ import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-di
|
|
|
3
3
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
4
4
|
import type { EditorState, SelectionBookmark } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import type { AnnotationInfo, InlineCommentAnnotationProvider } from '../types';
|
|
6
|
+
import type { AnnotationInfo, InlineCommentAnnotationProvider, TargetType } from '../types';
|
|
7
7
|
export declare enum ACTIONS {
|
|
8
8
|
UPDATE_INLINE_COMMENT_STATE = 0,
|
|
9
9
|
SET_INLINE_COMMENT_DRAFT_STATE = 1,
|
|
@@ -35,6 +35,7 @@ export type InlineCommentAction = {
|
|
|
35
35
|
data: {
|
|
36
36
|
drafting: boolean;
|
|
37
37
|
editorState: EditorState;
|
|
38
|
+
targetType?: TargetType;
|
|
38
39
|
};
|
|
39
40
|
} | {
|
|
40
41
|
type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
|
|
@@ -2,4 +2,4 @@ import type { IntlShape } from 'react-intl-next';
|
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { FloatingToolbarConfig } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (state: EditorState, intl: IntlShape, isToolbarAbove?: boolean) => FloatingToolbarConfig | undefined;
|
|
5
|
+
export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (state: EditorState, intl: IntlShape, isToolbarAbove?: boolean, isCommentOnMediaOn?: boolean, _supportedNodes?: string[]) => FloatingToolbarConfig | undefined;
|
|
@@ -1,22 +1,40 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import type { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
3
|
+
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import type { AnnotationUpdateEmitter } from '@atlaskit/editor-common/annotation';
|
|
4
|
-
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
5
6
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
6
7
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
8
|
+
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
7
9
|
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
8
10
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
9
11
|
import type { InlineCommentPluginState } from './pm-plugins/types';
|
|
10
12
|
type StripNonExistingAnnotations = (slice: Slice, state: EditorState) => boolean | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* type of target that annotation apply to.
|
|
15
|
+
* This is used to apply correct decoration to a draft comment
|
|
16
|
+
*/
|
|
17
|
+
export type TargetType = 'block' | 'inline';
|
|
18
|
+
/**
|
|
19
|
+
* The source of draft comment being created
|
|
20
|
+
*/
|
|
21
|
+
export type InlineCommentInputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB;
|
|
22
|
+
type SetInlineCommentDraftState = (drafting: boolean, inputMethod: InlineCommentInputMethod,
|
|
23
|
+
/** @default 'inline' */
|
|
24
|
+
targetType?: TargetType,
|
|
25
|
+
/** check for platform_editor_media_comments_base feature gate */
|
|
26
|
+
isCommentOnMediaOn?: boolean) => Command;
|
|
11
27
|
export type AnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
12
28
|
pluginConfiguration: AnnotationProviders | undefined;
|
|
13
29
|
sharedState: InlineCommentPluginState | undefined;
|
|
14
30
|
dependencies: [
|
|
15
31
|
OptionalPlugin<AnalyticsPlugin>,
|
|
16
|
-
OptionalPlugin<EditorViewModePlugin
|
|
32
|
+
OptionalPlugin<EditorViewModePlugin>,
|
|
33
|
+
OptionalPlugin<FeatureFlagsPlugin>
|
|
17
34
|
];
|
|
18
35
|
actions: {
|
|
19
36
|
stripNonExistingAnnotations: StripNonExistingAnnotations;
|
|
37
|
+
setInlineCommentDraftState: SetInlineCommentDraftState;
|
|
20
38
|
};
|
|
21
39
|
}>;
|
|
22
40
|
export type AnnotationInfo = {
|
|
@@ -79,6 +97,16 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
|
|
|
79
97
|
createComponent?: React.ComponentType<InlineCommentCreateComponentProps>;
|
|
80
98
|
viewComponent?: React.ComponentType<InlineCommentViewComponentProps>;
|
|
81
99
|
isToolbarAbove?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* @experimental Still under development. Do not use.
|
|
102
|
+
*
|
|
103
|
+
* A list of supported editor node names for inline comment,
|
|
104
|
+
* Note 1: value is the type name of the node, e.g. media, mediaInline
|
|
105
|
+
* Invalid node names, nodes does not support annotation
|
|
106
|
+
* or nodes not supported by current ADF schema will be ignored.
|
|
107
|
+
* Note 2: text is supported by default.
|
|
108
|
+
*/
|
|
109
|
+
supportedBlockNodes?: string[];
|
|
82
110
|
};
|
|
83
111
|
export interface AnnotationProviders {
|
|
84
112
|
inlineComment: InlineCommentAnnotationProvider;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { AnalyticsEventPayloadCallback
|
|
1
|
+
import type { AnalyticsEventPayloadCallback } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { containsAnyAnnotations, hasAnnotationMark } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import type { Mark, Node, ResolvedPos, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { AllSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import type { InlineCommentPluginState } from './pm-plugins/types';
|
|
8
|
-
import type { AnnotationInfo } from './types';
|
|
8
|
+
import type { AnnotationInfo, InlineCommentInputMethod, TargetType } from './types';
|
|
9
9
|
import { AnnotationSelectionType } from './types';
|
|
10
10
|
export { hasAnnotationMark, containsAnyAnnotations };
|
|
11
11
|
/**
|
|
@@ -14,7 +14,7 @@ export { hasAnnotationMark, containsAnyAnnotations };
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const surroundingMarks: ($pos: ResolvedPos) => (readonly Mark[])[];
|
|
16
16
|
export declare const getAllAnnotations: (doc: Node) => string[];
|
|
17
|
-
export declare const addDraftDecoration: (start: number, end: number) => Decoration;
|
|
17
|
+
export declare const addDraftDecoration: (start: number, end: number, targetType?: TargetType) => Decoration;
|
|
18
18
|
export declare const getAnnotationViewKey: (annotations: AnnotationInfo[]) => string;
|
|
19
19
|
export declare const findAnnotationsInSelection: (selection: Selection, doc: Node) => AnnotationInfo[];
|
|
20
20
|
/**
|
|
@@ -27,8 +27,8 @@ export declare const getPluginState: (state: EditorState) => InlineCommentPlugin
|
|
|
27
27
|
/**
|
|
28
28
|
* get payload for the open/close analytics event
|
|
29
29
|
*/
|
|
30
|
-
export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod:
|
|
31
|
-
export declare const isSelectionValid: (state: EditorState) => AnnotationSelectionType;
|
|
30
|
+
export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: InlineCommentInputMethod) => AnalyticsEventPayloadCallback;
|
|
31
|
+
export declare const isSelectionValid: (state: EditorState, isCommentOnMediaOn?: boolean, _supportedNodes?: string[]) => AnnotationSelectionType;
|
|
32
32
|
export declare const hasInvalidNodes: (state: EditorState) => boolean;
|
|
33
33
|
/**
|
|
34
34
|
* Checks if any of the nodes in a given selection are completely whitespace
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Annotation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,9 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/adf-schema": "^35.5.2",
|
|
36
|
-
"@atlaskit/editor-common": "^78.
|
|
36
|
+
"@atlaskit/editor-common": "^78.11.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-editor-viewmode": "^1.0.0",
|
|
39
|
+
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
39
40
|
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
40
41
|
"@atlaskit/icon": "^22.1.0",
|
|
41
42
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|