@atlaskit/editor-plugin-annotation 1.5.2 → 1.5.3
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 +6 -0
- package/dist/cjs/commands/index.js +32 -16
- package/dist/cjs/utils.js +5 -1
- package/dist/es2019/commands/index.js +26 -10
- package/dist/es2019/utils.js +1 -1
- package/dist/esm/commands/index.js +33 -17
- package/dist/esm/utils.js +5 -1
- package/dist/types/commands/index.d.ts +5 -1
- package/dist/types/commands/transform.d.ts +1 -1
- package/dist/types/types.d.ts +2 -2
- package/dist/types-ts4.5/commands/index.d.ts +5 -1
- package/dist/types-ts4.5/commands/transform.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 1.5.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#84432](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/84432) [`19324d1894bb`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/19324d1894bb) - [ED-22643] Update showInlineCommentForBlockNode so that it can dispatch action to show comment view component when there are no active comments associated with the give node
|
|
8
|
+
|
|
3
9
|
## 1.5.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -118,27 +118,43 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
|
|
|
118
118
|
};
|
|
119
119
|
};
|
|
120
120
|
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Show active inline comments for a given block node, otherwise,
|
|
124
|
+
* return false if the node has no comments or no unresolved comments.
|
|
125
|
+
*/
|
|
121
126
|
var showInlineCommentForBlockNode = exports.showInlineCommentForBlockNode = function showInlineCommentForBlockNode() {
|
|
122
127
|
var supportedBlockNodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
123
128
|
return function (node) {
|
|
124
|
-
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
type: _types.ACTIONS.SET_SELECTED_ANNOTATION,
|
|
136
|
-
data: {
|
|
137
|
-
selectedAnnotations: annotationMarks
|
|
138
|
-
}
|
|
129
|
+
return function (state, dispatch) {
|
|
130
|
+
var pluginState = (0, _utils.getPluginState)(state);
|
|
131
|
+
var annotation = state.schema.marks.annotation;
|
|
132
|
+
if (node && node.isBlock && supportedBlockNodes.includes(node.type.name)) {
|
|
133
|
+
var unresolvedAnnotationMarks = ((node === null || node === void 0 ? void 0 : node.marks) || []).filter(function (mark) {
|
|
134
|
+
return mark.type === annotation && !(pluginState !== null && pluginState !== void 0 && pluginState.annotations[mark.attrs.id]);
|
|
135
|
+
}).map(function (mark) {
|
|
136
|
+
return {
|
|
137
|
+
id: mark.attrs.id,
|
|
138
|
+
type: mark.attrs.annotationType
|
|
139
|
+
};
|
|
139
140
|
});
|
|
141
|
+
if (unresolvedAnnotationMarks.length) {
|
|
142
|
+
if (dispatch) {
|
|
143
|
+
// bypass createCommand with setMeta
|
|
144
|
+
// so that external plugins can be aware of if there are active(unresolved) comments associated with the node
|
|
145
|
+
// i.e. media plugin can use the return result (true/false) to show toggle create comment component
|
|
146
|
+
dispatch(state.tr.setMeta(_utils.inlineCommentPluginKey, {
|
|
147
|
+
type: _types.ACTIONS.SET_SELECTED_ANNOTATION,
|
|
148
|
+
data: {
|
|
149
|
+
selectedAnnotations: unresolvedAnnotationMarks
|
|
150
|
+
}
|
|
151
|
+
}));
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
140
155
|
}
|
|
141
|
-
|
|
156
|
+
return false;
|
|
157
|
+
};
|
|
142
158
|
};
|
|
143
159
|
};
|
|
144
160
|
var setInlineCommentDraftState = exports.setInlineCommentDraftState = function setInlineCommentDraftState(editorAnalyticsAPI) {
|
package/dist/cjs/utils.js
CHANGED
|
@@ -463,7 +463,11 @@ var isBlockNodeAnnotationsSelected = exports.isBlockNodeAnnotationsSelected = fu
|
|
|
463
463
|
type: mark.attrs.annotationType
|
|
464
464
|
};
|
|
465
465
|
})) || [];
|
|
466
|
-
return !
|
|
466
|
+
return !selectedAnnotations.some(function (annotation) {
|
|
467
|
+
return !annotationMarks.find(function (existingAnnotation) {
|
|
468
|
+
return existingAnnotation.id === annotation.id && existingAnnotation.type === annotation.type;
|
|
469
|
+
});
|
|
470
|
+
});
|
|
467
471
|
}
|
|
468
472
|
return false;
|
|
469
473
|
};
|
|
@@ -4,7 +4,7 @@ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
4
4
|
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
5
5
|
import { ACTIONS } from '../pm-plugins/types';
|
|
6
6
|
import { AnnotationSelectionType } from '../types';
|
|
7
|
-
import { getPluginState, isSelectionValid, isSupportedBlockNode } from '../utils';
|
|
7
|
+
import { getPluginState, inlineCommentPluginKey, isSelectionValid, isSupportedBlockNode } from '../utils';
|
|
8
8
|
import transform from './transform';
|
|
9
9
|
export const updateInlineCommentResolvedState = editorAnalyticsAPI => (partialNewState, resolveMethod) => {
|
|
10
10
|
const command = {
|
|
@@ -104,21 +104,37 @@ const getDraftCommandAction = (drafting, targetType, isCommentOnMediaOn, support
|
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
|
-
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Show active inline comments for a given block node, otherwise,
|
|
110
|
+
* return false if the node has no comments or no unresolved comments.
|
|
111
|
+
*/
|
|
112
|
+
export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => node => (state, dispatch) => {
|
|
113
|
+
const pluginState = getPluginState(state);
|
|
114
|
+
const {
|
|
115
|
+
annotation
|
|
116
|
+
} = state.schema.marks;
|
|
108
117
|
if (node && node.isBlock && supportedBlockNodes.includes(node.type.name)) {
|
|
109
|
-
const
|
|
118
|
+
const unresolvedAnnotationMarks = ((node === null || node === void 0 ? void 0 : node.marks) || []).filter(mark => mark.type === annotation && !(pluginState !== null && pluginState !== void 0 && pluginState.annotations[mark.attrs.id])).map(mark => ({
|
|
110
119
|
id: mark.attrs.id,
|
|
111
120
|
type: mark.attrs.annotationType
|
|
112
121
|
}));
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
if (unresolvedAnnotationMarks.length) {
|
|
123
|
+
if (dispatch) {
|
|
124
|
+
// bypass createCommand with setMeta
|
|
125
|
+
// so that external plugins can be aware of if there are active(unresolved) comments associated with the node
|
|
126
|
+
// i.e. media plugin can use the return result (true/false) to show toggle create comment component
|
|
127
|
+
dispatch(state.tr.setMeta(inlineCommentPluginKey, {
|
|
128
|
+
type: ACTIONS.SET_SELECTED_ANNOTATION,
|
|
129
|
+
data: {
|
|
130
|
+
selectedAnnotations: unresolvedAnnotationMarks
|
|
131
|
+
}
|
|
132
|
+
}));
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
120
135
|
}
|
|
121
136
|
}
|
|
137
|
+
return false;
|
|
122
138
|
};
|
|
123
139
|
export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = []) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', isCommentOnMediaOn = false) => {
|
|
124
140
|
const commandAction = getDraftCommandAction(drafting, targetType, isCommentOnMediaOn, supportedBlockNodes);
|
package/dist/es2019/utils.js
CHANGED
|
@@ -422,7 +422,7 @@ export const isBlockNodeAnnotationsSelected = (selection, selectedAnnotations =
|
|
|
422
422
|
id: mark.attrs.id,
|
|
423
423
|
type: mark.attrs.annotationType
|
|
424
424
|
}))) || [];
|
|
425
|
-
return !
|
|
425
|
+
return !selectedAnnotations.some(annotation => !annotationMarks.find(existingAnnotation => existingAnnotation.id === annotation.id && existingAnnotation.type === annotation.type));
|
|
426
426
|
}
|
|
427
427
|
return false;
|
|
428
428
|
};
|
|
@@ -5,7 +5,7 @@ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
5
5
|
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
6
6
|
import { ACTIONS } from '../pm-plugins/types';
|
|
7
7
|
import { AnnotationSelectionType } from '../types';
|
|
8
|
-
import { getPluginState, isSelectionValid, isSupportedBlockNode } from '../utils';
|
|
8
|
+
import { getPluginState, inlineCommentPluginKey, isSelectionValid, isSupportedBlockNode } from '../utils';
|
|
9
9
|
import transform from './transform';
|
|
10
10
|
export var updateInlineCommentResolvedState = function updateInlineCommentResolvedState(editorAnalyticsAPI) {
|
|
11
11
|
return function (partialNewState, resolveMethod) {
|
|
@@ -111,27 +111,43 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
|
|
|
111
111
|
};
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Show active inline comments for a given block node, otherwise,
|
|
117
|
+
* return false if the node has no comments or no unresolved comments.
|
|
118
|
+
*/
|
|
114
119
|
export var showInlineCommentForBlockNode = function showInlineCommentForBlockNode() {
|
|
115
120
|
var supportedBlockNodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
116
121
|
return function (node) {
|
|
117
|
-
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
type: ACTIONS.SET_SELECTED_ANNOTATION,
|
|
129
|
-
data: {
|
|
130
|
-
selectedAnnotations: annotationMarks
|
|
131
|
-
}
|
|
122
|
+
return function (state, dispatch) {
|
|
123
|
+
var pluginState = getPluginState(state);
|
|
124
|
+
var annotation = state.schema.marks.annotation;
|
|
125
|
+
if (node && node.isBlock && supportedBlockNodes.includes(node.type.name)) {
|
|
126
|
+
var unresolvedAnnotationMarks = ((node === null || node === void 0 ? void 0 : node.marks) || []).filter(function (mark) {
|
|
127
|
+
return mark.type === annotation && !(pluginState !== null && pluginState !== void 0 && pluginState.annotations[mark.attrs.id]);
|
|
128
|
+
}).map(function (mark) {
|
|
129
|
+
return {
|
|
130
|
+
id: mark.attrs.id,
|
|
131
|
+
type: mark.attrs.annotationType
|
|
132
|
+
};
|
|
132
133
|
});
|
|
134
|
+
if (unresolvedAnnotationMarks.length) {
|
|
135
|
+
if (dispatch) {
|
|
136
|
+
// bypass createCommand with setMeta
|
|
137
|
+
// so that external plugins can be aware of if there are active(unresolved) comments associated with the node
|
|
138
|
+
// i.e. media plugin can use the return result (true/false) to show toggle create comment component
|
|
139
|
+
dispatch(state.tr.setMeta(inlineCommentPluginKey, {
|
|
140
|
+
type: ACTIONS.SET_SELECTED_ANNOTATION,
|
|
141
|
+
data: {
|
|
142
|
+
selectedAnnotations: unresolvedAnnotationMarks
|
|
143
|
+
}
|
|
144
|
+
}));
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
133
148
|
}
|
|
134
|
-
|
|
149
|
+
return false;
|
|
150
|
+
};
|
|
135
151
|
};
|
|
136
152
|
};
|
|
137
153
|
export var setInlineCommentDraftState = function setInlineCommentDraftState(editorAnalyticsAPI) {
|
package/dist/esm/utils.js
CHANGED
|
@@ -436,7 +436,11 @@ export var isBlockNodeAnnotationsSelected = function isBlockNodeAnnotationsSelec
|
|
|
436
436
|
type: mark.attrs.annotationType
|
|
437
437
|
};
|
|
438
438
|
})) || [];
|
|
439
|
-
return !
|
|
439
|
+
return !selectedAnnotations.some(function (annotation) {
|
|
440
|
+
return !annotationMarks.find(function (existingAnnotation) {
|
|
441
|
+
return existingAnnotation.id === annotation.id && existingAnnotation.type === annotation.type;
|
|
442
|
+
});
|
|
443
|
+
});
|
|
440
444
|
}
|
|
441
445
|
return false;
|
|
442
446
|
};
|
|
@@ -8,7 +8,11 @@ export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: Edit
|
|
|
8
8
|
export declare const closeComponent: () => Command;
|
|
9
9
|
export declare const clearDirtyMark: () => Command;
|
|
10
10
|
export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[]) => Command;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Show active inline comments for a given block node, otherwise,
|
|
13
|
+
* return false if the node has no comments or no unresolved comments.
|
|
14
|
+
*/
|
|
15
|
+
export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null) => Command;
|
|
12
16
|
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
|
|
13
17
|
export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
|
|
14
18
|
export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
|
|
@@ -69,7 +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
|
|
72
|
+
showCommentForBlockNode: (node: import("prosemirror-model").Node | null) => import("@atlaskit/editor-common/types").Command;
|
|
73
73
|
};
|
|
74
74
|
}, import("../types").AnnotationProviders | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
|
|
75
75
|
pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -38,8 +38,8 @@ export type AnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
|
38
38
|
setInlineCommentDraftState: SetInlineCommentDraftState;
|
|
39
39
|
/**
|
|
40
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
|
|
42
|
-
* otherwise, it will return
|
|
41
|
+
* @returns A command function that returns true if the given node is supported and has resolved annotation mark(s);
|
|
42
|
+
* otherwise, it will return false.
|
|
43
43
|
*/
|
|
44
44
|
showCommentForBlockNode: ReturnType<typeof showInlineCommentForBlockNode>;
|
|
45
45
|
};
|
|
@@ -8,7 +8,11 @@ export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: Edit
|
|
|
8
8
|
export declare const closeComponent: () => Command;
|
|
9
9
|
export declare const clearDirtyMark: () => Command;
|
|
10
10
|
export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[]) => Command;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Show active inline comments for a given block node, otherwise,
|
|
13
|
+
* return false if the node has no comments or no unresolved comments.
|
|
14
|
+
*/
|
|
15
|
+
export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null) => Command;
|
|
12
16
|
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
|
|
13
17
|
export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
|
|
14
18
|
export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
|
|
@@ -83,7 +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
|
|
86
|
+
showCommentForBlockNode: (node: import("prosemirror-model").Node | null) => import("@atlaskit/editor-common/types").Command;
|
|
87
87
|
};
|
|
88
88
|
}, import("../types").AnnotationProviders | undefined>,
|
|
89
89
|
import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
|
|
@@ -38,8 +38,8 @@ export type AnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
|
38
38
|
setInlineCommentDraftState: SetInlineCommentDraftState;
|
|
39
39
|
/**
|
|
40
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
|
|
42
|
-
* otherwise, it will return
|
|
41
|
+
* @returns A command function that returns true if the given node is supported and has resolved annotation mark(s);
|
|
42
|
+
* otherwise, it will return false.
|
|
43
43
|
*/
|
|
44
44
|
showCommentForBlockNode: ReturnType<typeof showInlineCommentForBlockNode>;
|
|
45
45
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "Annotation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/adf-schema": "^35.7.0",
|
|
36
|
-
"@atlaskit/editor-common": "^78.
|
|
36
|
+
"@atlaskit/editor-common": "^78.21.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",
|