@atlaskit/editor-plugin-annotation 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/commands/index.js +24 -1
- package/dist/cjs/plugin.js +2 -1
- package/dist/cjs/pm-plugins/inline-comment.js +4 -5
- package/dist/cjs/pm-plugins/plugin-factory.js +5 -0
- package/dist/cjs/toolbar.js +2 -0
- package/dist/es2019/commands/index.js +16 -0
- package/dist/es2019/plugin.js +3 -2
- package/dist/es2019/pm-plugins/inline-comment.js +3 -4
- package/dist/es2019/pm-plugins/plugin-factory.js +5 -0
- package/dist/es2019/toolbar.js +2 -0
- package/dist/esm/commands/index.js +23 -0
- package/dist/esm/plugin.js +3 -2
- package/dist/esm/pm-plugins/inline-comment.js +5 -6
- package/dist/esm/pm-plugins/plugin-factory.js +5 -0
- package/dist/esm/toolbar.js +2 -0
- package/dist/types/commands/index.d.ts +2 -0
- package/dist/types/commands/transform.d.ts +1 -0
- package/dist/types/pm-plugins/plugin-factory.d.ts +1 -1
- package/dist/types/types.d.ts +9 -2
- package/dist/types-ts4.5/commands/index.d.ts +2 -0
- package/dist/types-ts4.5/commands/transform.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +9 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 1.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#82581](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/82581) [`c1be75ae15b6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c1be75ae15b6) - ED-22606 add toggle inline comment action
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#81777](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/81777) [`c6d7a5378751`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c6d7a5378751) - Bump adf-schema to 35.7.0
|
|
12
|
+
|
|
13
|
+
## 1.4.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#83116](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83116) [`8d4e99057fe0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8d4e99057fe0) - Upgrade Typescript from `4.9.5` to `5.4.2`
|
|
18
|
+
|
|
3
19
|
## 1.4.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.updateMouseState = exports.updateInlineCommentResolvedState = exports.setSelectedAnnotation = exports.setInlineCommentsVisibility = exports.setInlineCommentDraftState = exports.removeInlineCommentNearSelection = exports.createAnnotation = exports.closeComponent = exports.clearDirtyMark = exports.addInlineComment = void 0;
|
|
7
|
+
exports.updateMouseState = exports.updateInlineCommentResolvedState = exports.showInlineCommentForBlockNode = exports.setSelectedAnnotation = exports.setInlineCommentsVisibility = exports.setInlineCommentDraftState = exports.removeInlineCommentNearSelection = exports.createAnnotation = exports.closeComponent = exports.clearDirtyMark = exports.addInlineComment = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -118,6 +118,29 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
|
|
|
118
118
|
};
|
|
119
119
|
};
|
|
120
120
|
};
|
|
121
|
+
var showInlineCommentForBlockNode = exports.showInlineCommentForBlockNode = function showInlineCommentForBlockNode() {
|
|
122
|
+
var supportedBlockNodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
123
|
+
return function (node) {
|
|
124
|
+
if (node && node.isBlock && supportedBlockNodes.includes(node.type.name)) {
|
|
125
|
+
var annotationMarks = ((node === null || node === void 0 ? void 0 : node.marks) || []).filter(function (mark) {
|
|
126
|
+
return mark.type.name === 'annotation';
|
|
127
|
+
}).map(function (mark) {
|
|
128
|
+
return {
|
|
129
|
+
id: mark.attrs.id,
|
|
130
|
+
type: mark.attrs.annotationType
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
if (annotationMarks.length) {
|
|
134
|
+
return (0, _pluginFactory.createCommand)({
|
|
135
|
+
type: _types.ACTIONS.SET_SELECTED_ANNOTATION,
|
|
136
|
+
data: {
|
|
137
|
+
selectedAnnotations: annotationMarks
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
};
|
|
121
144
|
var setInlineCommentDraftState = exports.setInlineCommentDraftState = function setInlineCommentDraftState(editorAnalyticsAPI) {
|
|
122
145
|
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
123
146
|
return function (drafting) {
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -37,7 +37,8 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
37
37
|
},
|
|
38
38
|
actions: {
|
|
39
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, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
|
|
40
|
+
setInlineCommentDraftState: (0, _commands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
|
|
41
|
+
showCommentForBlockNode: (0, _commands.showInlineCommentForBlockNode)(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
|
|
41
42
|
},
|
|
42
43
|
getSharedState: function getSharedState(editorState) {
|
|
43
44
|
if (!editorState) {
|
|
@@ -231,18 +231,17 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
231
231
|
}).forEach(function (mark) {
|
|
232
232
|
if (isVisible) {
|
|
233
233
|
var isUnresolved = !!annotations && annotations[mark.attrs.id] === false;
|
|
234
|
+
var isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
|
|
235
|
+
return selectedAnnotation.id === mark.attrs.id;
|
|
236
|
+
}));
|
|
234
237
|
if (isSupportedBlockNode) {
|
|
235
|
-
var isBlockNodeSelected = (0, _utils.isCurrentBlockNodeSelected)(state, node);
|
|
236
238
|
var attrs = isUnresolved ? {
|
|
237
|
-
class:
|
|
239
|
+
class: isSelected ? "".concat(_styles.BlockAnnotationSharedClassNames.focus) : "".concat(_styles.BlockAnnotationSharedClassNames.blur)
|
|
238
240
|
} : {};
|
|
239
241
|
focusDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, attrs, {
|
|
240
242
|
key: _utils.decorationKey.block
|
|
241
243
|
}));
|
|
242
244
|
} else {
|
|
243
|
-
var isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
|
|
244
|
-
return selectedAnnotation.id === mark.attrs.id;
|
|
245
|
-
}));
|
|
246
245
|
focusDecorations.push(_view.Decoration.inline(pos, pos + node.nodeSize, {
|
|
247
246
|
class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved),
|
|
248
247
|
nodeName: 'span'
|
|
@@ -29,6 +29,11 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
|
|
|
29
29
|
isInlineCommentViewClosed: false
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Default we only handle caret selections.
|
|
35
|
+
* Node selection will be handled separately.
|
|
36
|
+
*/
|
|
32
37
|
var selectedAnnotations = (0, _utils2.findAnnotationsInSelection)(tr.selection, tr.doc);
|
|
33
38
|
if (selectedAnnotations.length === 0) {
|
|
34
39
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -50,6 +50,8 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
|
|
|
50
50
|
eventType: _analytics.EVENT_TYPE.UI,
|
|
51
51
|
attributes: {
|
|
52
52
|
source: 'highlightActionsMenu',
|
|
53
|
+
// @ts-expect-error - Object literal may only specify known properties, and 'pageMode' does not exist in type
|
|
54
|
+
// This error was introduced after upgrading to TypeScript 5
|
|
53
55
|
pageMode: 'edit'
|
|
54
56
|
}
|
|
55
57
|
});
|
|
@@ -104,6 +104,22 @@ const getDraftCommandAction = (drafting, targetType, isCommentOnMediaOn, support
|
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
|
+
export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => node => {
|
|
108
|
+
if (node && node.isBlock && supportedBlockNodes.includes(node.type.name)) {
|
|
109
|
+
const annotationMarks = ((node === null || node === void 0 ? void 0 : node.marks) || []).filter(mark => mark.type.name === 'annotation').map(mark => ({
|
|
110
|
+
id: mark.attrs.id,
|
|
111
|
+
type: mark.attrs.annotationType
|
|
112
|
+
}));
|
|
113
|
+
if (annotationMarks.length) {
|
|
114
|
+
return createCommand({
|
|
115
|
+
type: ACTIONS.SET_SELECTED_ANNOTATION,
|
|
116
|
+
data: {
|
|
117
|
+
selectedAnnotations: annotationMarks
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
107
123
|
export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = []) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', isCommentOnMediaOn = false) => {
|
|
108
124
|
const commandAction = getDraftCommandAction(drafting, targetType, isCommentOnMediaOn, supportedBlockNodes);
|
|
109
125
|
return createCommand(commandAction, transform.addOpenCloseAnalytics(editorAnalyticsAPI)(drafting, inputMethod));
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -3,7 +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
|
+
import { setInlineCommentDraftState, showInlineCommentForBlockNode } from './commands';
|
|
7
7
|
import { inlineCommentPlugin } from './pm-plugins/inline-comment';
|
|
8
8
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
9
9
|
import { buildToolbar } from './toolbar';
|
|
@@ -25,7 +25,8 @@ export const annotationPlugin = ({
|
|
|
25
25
|
},
|
|
26
26
|
actions: {
|
|
27
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, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
|
|
28
|
+
setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
|
|
29
|
+
showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
|
|
29
30
|
},
|
|
30
31
|
getSharedState(editorState) {
|
|
31
32
|
if (!editorState) {
|
|
@@ -5,7 +5,7 @@ import { BlockAnnotationSharedClassNames } from '@atlaskit/editor-common/styles'
|
|
|
5
5
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import { clearDirtyMark, closeComponent, setInlineCommentsVisibility, setSelectedAnnotation, updateInlineCommentResolvedState, updateMouseState } from '../commands';
|
|
7
7
|
import { AnnotationNodeView, getAnnotationViewClassname } from '../nodeviews';
|
|
8
|
-
import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey
|
|
8
|
+
import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from '../utils';
|
|
9
9
|
import { createPluginState } from './plugin-factory';
|
|
10
10
|
const fetchProviderStates = async (provider, annotationIds) => {
|
|
11
11
|
const data = await provider.getState(annotationIds);
|
|
@@ -169,16 +169,15 @@ export const inlineCommentPlugin = options => {
|
|
|
169
169
|
node.marks.filter(mark => mark.type === state.schema.marks.annotation).forEach(mark => {
|
|
170
170
|
if (isVisible) {
|
|
171
171
|
const isUnresolved = !!annotations && annotations[mark.attrs.id] === false;
|
|
172
|
+
const isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(selectedAnnotation => selectedAnnotation.id === mark.attrs.id));
|
|
172
173
|
if (isSupportedBlockNode) {
|
|
173
|
-
const isBlockNodeSelected = isCurrentBlockNodeSelected(state, node);
|
|
174
174
|
const attrs = isUnresolved ? {
|
|
175
|
-
class:
|
|
175
|
+
class: isSelected ? `${BlockAnnotationSharedClassNames.focus}` : `${BlockAnnotationSharedClassNames.blur}`
|
|
176
176
|
} : {};
|
|
177
177
|
focusDecorations.push(Decoration.node(pos, pos + node.nodeSize, attrs, {
|
|
178
178
|
key: decorationKey.block
|
|
179
179
|
}));
|
|
180
180
|
} else {
|
|
181
|
-
const isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(selectedAnnotation => selectedAnnotation.id === mark.attrs.id));
|
|
182
181
|
focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
|
|
183
182
|
class: `${getAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`,
|
|
184
183
|
nodeName: 'span'
|
|
@@ -21,6 +21,11 @@ const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => {
|
|
|
21
21
|
})
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Default we only handle caret selections.
|
|
27
|
+
* Node selection will be handled separately.
|
|
28
|
+
*/
|
|
24
29
|
const selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
|
|
25
30
|
if (selectedAnnotations.length === 0) {
|
|
26
31
|
return {
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -41,6 +41,8 @@ export const buildToolbar = editorAnalyticsAPI => (state, intl, isToolbarAbove =
|
|
|
41
41
|
eventType: EVENT_TYPE.UI,
|
|
42
42
|
attributes: {
|
|
43
43
|
source: 'highlightActionsMenu',
|
|
44
|
+
// @ts-expect-error - Object literal may only specify known properties, and 'pageMode' does not exist in type
|
|
45
|
+
// This error was introduced after upgrading to TypeScript 5
|
|
44
46
|
pageMode: 'edit'
|
|
45
47
|
}
|
|
46
48
|
});
|
|
@@ -111,6 +111,29 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
|
|
|
111
111
|
};
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
|
+
export var showInlineCommentForBlockNode = function showInlineCommentForBlockNode() {
|
|
115
|
+
var supportedBlockNodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
116
|
+
return function (node) {
|
|
117
|
+
if (node && node.isBlock && supportedBlockNodes.includes(node.type.name)) {
|
|
118
|
+
var annotationMarks = ((node === null || node === void 0 ? void 0 : node.marks) || []).filter(function (mark) {
|
|
119
|
+
return mark.type.name === 'annotation';
|
|
120
|
+
}).map(function (mark) {
|
|
121
|
+
return {
|
|
122
|
+
id: mark.attrs.id,
|
|
123
|
+
type: mark.attrs.annotationType
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
if (annotationMarks.length) {
|
|
127
|
+
return createCommand({
|
|
128
|
+
type: ACTIONS.SET_SELECTED_ANNOTATION,
|
|
129
|
+
data: {
|
|
130
|
+
selectedAnnotations: annotationMarks
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
};
|
|
114
137
|
export var setInlineCommentDraftState = function setInlineCommentDraftState(editorAnalyticsAPI) {
|
|
115
138
|
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
116
139
|
return function (drafting) {
|
package/dist/esm/plugin.js
CHANGED
|
@@ -3,7 +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
|
+
import { setInlineCommentDraftState, showInlineCommentForBlockNode } from './commands';
|
|
7
7
|
import { inlineCommentPlugin } from './pm-plugins/inline-comment';
|
|
8
8
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
9
9
|
import { buildToolbar } from './toolbar';
|
|
@@ -24,7 +24,8 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
24
24
|
},
|
|
25
25
|
actions: {
|
|
26
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, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
|
|
27
|
+
setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
|
|
28
|
+
showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
|
|
28
29
|
},
|
|
29
30
|
getSharedState: function getSharedState(editorState) {
|
|
30
31
|
if (!editorState) {
|
|
@@ -8,7 +8,7 @@ import { BlockAnnotationSharedClassNames } from '@atlaskit/editor-common/styles'
|
|
|
8
8
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import { clearDirtyMark, closeComponent, setInlineCommentsVisibility, setSelectedAnnotation, updateInlineCommentResolvedState, updateMouseState } from '../commands';
|
|
10
10
|
import { AnnotationNodeView, getAnnotationViewClassname } from '../nodeviews';
|
|
11
|
-
import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey
|
|
11
|
+
import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from '../utils';
|
|
12
12
|
import { createPluginState } from './plugin-factory';
|
|
13
13
|
var fetchProviderStates = /*#__PURE__*/function () {
|
|
14
14
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(provider, annotationIds) {
|
|
@@ -224,18 +224,17 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
224
224
|
}).forEach(function (mark) {
|
|
225
225
|
if (isVisible) {
|
|
226
226
|
var isUnresolved = !!annotations && annotations[mark.attrs.id] === false;
|
|
227
|
+
var isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
|
|
228
|
+
return selectedAnnotation.id === mark.attrs.id;
|
|
229
|
+
}));
|
|
227
230
|
if (isSupportedBlockNode) {
|
|
228
|
-
var isBlockNodeSelected = isCurrentBlockNodeSelected(state, node);
|
|
229
231
|
var attrs = isUnresolved ? {
|
|
230
|
-
class:
|
|
232
|
+
class: isSelected ? "".concat(BlockAnnotationSharedClassNames.focus) : "".concat(BlockAnnotationSharedClassNames.blur)
|
|
231
233
|
} : {};
|
|
232
234
|
focusDecorations.push(Decoration.node(pos, pos + node.nodeSize, attrs, {
|
|
233
235
|
key: decorationKey.block
|
|
234
236
|
}));
|
|
235
237
|
} else {
|
|
236
|
-
var isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
|
|
237
|
-
return selectedAnnotation.id === mark.attrs.id;
|
|
238
|
-
}));
|
|
239
238
|
focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
|
|
240
239
|
class: "".concat(getAnnotationViewClassname(isUnresolved, isSelected), " ").concat(isUnresolved),
|
|
241
240
|
nodeName: 'span'
|
|
@@ -22,6 +22,11 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
|
|
|
22
22
|
isInlineCommentViewClosed: false
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Default we only handle caret selections.
|
|
28
|
+
* Node selection will be handled separately.
|
|
29
|
+
*/
|
|
25
30
|
var selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
|
|
26
31
|
if (selectedAnnotations.length === 0) {
|
|
27
32
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -43,6 +43,8 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
|
|
|
43
43
|
eventType: EVENT_TYPE.UI,
|
|
44
44
|
attributes: {
|
|
45
45
|
source: 'highlightActionsMenu',
|
|
46
|
+
// @ts-expect-error - Object literal may only specify known properties, and 'pageMode' does not exist in type
|
|
47
|
+
// This error was introduced after upgrading to TypeScript 5
|
|
46
48
|
pageMode: 'edit'
|
|
47
49
|
}
|
|
48
50
|
});
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { EditorAnalyticsAPI, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import type { InlineCommentMap, InlineCommentMouseData } from '../pm-plugins/types';
|
|
5
6
|
import type { AnnotationPlugin, InlineCommentInputMethod, TargetType } from '../types';
|
|
6
7
|
export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
|
|
7
8
|
export declare const closeComponent: () => Command;
|
|
8
9
|
export declare const clearDirtyMark: () => Command;
|
|
9
10
|
export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[]) => Command;
|
|
11
|
+
export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null) => Command | undefined;
|
|
10
12
|
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
|
|
11
13
|
export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string) => Command;
|
|
12
14
|
export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
|
|
@@ -69,6 +69,7 @@ declare const _default: {
|
|
|
69
69
|
actions: {
|
|
70
70
|
stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
|
|
71
71
|
setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
72
|
+
showCommentForBlockNode: (node: import("prosemirror-model").Node | null) => import("@atlaskit/editor-common/types").Command | undefined;
|
|
72
73
|
};
|
|
73
74
|
}, import("../types").AnnotationProviders | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
|
|
74
75
|
pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { InlineCommentPluginState } from './types';
|
|
2
|
-
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch
|
|
2
|
+
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: InlineCommentPluginState | ((state: import("prosemirror-state").EditorState) => InlineCommentPluginState)) => import("prosemirror-state").SafeStateField<InlineCommentPluginState>, createCommand: <A = import("./types").InlineCommentAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmo
|
|
|
8
8
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
9
9
|
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
10
10
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
+
import type { showInlineCommentForBlockNode } from './commands';
|
|
11
12
|
import type { InlineCommentPluginState } from './pm-plugins/types';
|
|
12
13
|
type StripNonExistingAnnotations = (slice: Slice, state: EditorState) => boolean | undefined;
|
|
13
14
|
/**
|
|
@@ -35,6 +36,12 @@ export type AnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
|
35
36
|
actions: {
|
|
36
37
|
stripNonExistingAnnotations: StripNonExistingAnnotations;
|
|
37
38
|
setInlineCommentDraftState: SetInlineCommentDraftState;
|
|
39
|
+
/**
|
|
40
|
+
* This function attempts to display the inline comment popup for a given node.
|
|
41
|
+
* @returns A command function if the given node is supported and has an annotation mark;
|
|
42
|
+
* otherwise, it will return undefined.
|
|
43
|
+
*/
|
|
44
|
+
showCommentForBlockNode: ReturnType<typeof showInlineCommentForBlockNode>;
|
|
38
45
|
};
|
|
39
46
|
}>;
|
|
40
47
|
export type AnnotationInfo = {
|
|
@@ -112,8 +119,8 @@ export interface AnnotationProviders {
|
|
|
112
119
|
inlineComment: InlineCommentAnnotationProvider;
|
|
113
120
|
}
|
|
114
121
|
export declare enum AnnotationSelectionType {
|
|
115
|
-
INVALID = "invalid",
|
|
116
|
-
DISABLED = "disabled",
|
|
122
|
+
INVALID = "invalid",// Annotation should not be created, toolbar should not be shown
|
|
123
|
+
DISABLED = "disabled",// Annotation should not be created, toolbar should be shown, but disabled
|
|
117
124
|
VALID = "valid"
|
|
118
125
|
}
|
|
119
126
|
export declare const AnnotationTestIds: {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { EditorAnalyticsAPI, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import type { InlineCommentMap, InlineCommentMouseData } from '../pm-plugins/types';
|
|
5
6
|
import type { AnnotationPlugin, InlineCommentInputMethod, TargetType } from '../types';
|
|
6
7
|
export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
|
|
7
8
|
export declare const closeComponent: () => Command;
|
|
8
9
|
export declare const clearDirtyMark: () => Command;
|
|
9
10
|
export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[]) => Command;
|
|
11
|
+
export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null) => Command | undefined;
|
|
10
12
|
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
|
|
11
13
|
export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string) => Command;
|
|
12
14
|
export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
|
|
@@ -83,6 +83,7 @@ declare const _default: {
|
|
|
83
83
|
actions: {
|
|
84
84
|
stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
|
|
85
85
|
setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
86
|
+
showCommentForBlockNode: (node: import("prosemirror-model").Node | null) => import("@atlaskit/editor-common/types").Command | undefined;
|
|
86
87
|
};
|
|
87
88
|
}, import("../types").AnnotationProviders | undefined>,
|
|
88
89
|
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { InlineCommentPluginState } from './types';
|
|
2
|
-
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch
|
|
2
|
+
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: InlineCommentPluginState | ((state: import("prosemirror-state").EditorState) => InlineCommentPluginState)) => import("prosemirror-state").SafeStateField<InlineCommentPluginState>, createCommand: <A = import("./types").InlineCommentAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
@@ -8,6 +8,7 @@ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmo
|
|
|
8
8
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
9
9
|
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
10
10
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
+
import type { showInlineCommentForBlockNode } from './commands';
|
|
11
12
|
import type { InlineCommentPluginState } from './pm-plugins/types';
|
|
12
13
|
type StripNonExistingAnnotations = (slice: Slice, state: EditorState) => boolean | undefined;
|
|
13
14
|
/**
|
|
@@ -35,6 +36,12 @@ export type AnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
|
35
36
|
actions: {
|
|
36
37
|
stripNonExistingAnnotations: StripNonExistingAnnotations;
|
|
37
38
|
setInlineCommentDraftState: SetInlineCommentDraftState;
|
|
39
|
+
/**
|
|
40
|
+
* This function attempts to display the inline comment popup for a given node.
|
|
41
|
+
* @returns A command function if the given node is supported and has an annotation mark;
|
|
42
|
+
* otherwise, it will return undefined.
|
|
43
|
+
*/
|
|
44
|
+
showCommentForBlockNode: ReturnType<typeof showInlineCommentForBlockNode>;
|
|
38
45
|
};
|
|
39
46
|
}>;
|
|
40
47
|
export type AnnotationInfo = {
|
|
@@ -112,8 +119,8 @@ export interface AnnotationProviders {
|
|
|
112
119
|
inlineComment: InlineCommentAnnotationProvider;
|
|
113
120
|
}
|
|
114
121
|
export declare enum AnnotationSelectionType {
|
|
115
|
-
INVALID = "invalid",
|
|
116
|
-
DISABLED = "disabled",
|
|
122
|
+
INVALID = "invalid",// Annotation should not be created, toolbar should not be shown
|
|
123
|
+
DISABLED = "disabled",// Annotation should not be created, toolbar should be shown, but disabled
|
|
117
124
|
VALID = "valid"
|
|
118
125
|
}
|
|
119
126
|
export declare const AnnotationTestIds: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Annotation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
".": "./src/index.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@atlaskit/adf-schema": "^35.
|
|
36
|
-
"@atlaskit/editor-common": "^78.
|
|
35
|
+
"@atlaskit/adf-schema": "^35.7.0",
|
|
36
|
+
"@atlaskit/editor-common": "^78.18.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-editor-viewmode": "^1.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@atlassian/feature-flags-test-utils": "^0.2.0",
|
|
55
55
|
"@testing-library/react": "^12.1.5",
|
|
56
56
|
"react-dom": "^16.8.0",
|
|
57
|
-
"typescript": "~4.
|
|
57
|
+
"typescript": "~5.4.2",
|
|
58
58
|
"wait-for-expect": "^1.2.0"
|
|
59
59
|
},
|
|
60
60
|
"techstack": {
|