@atlaskit/editor-plugin-annotation 1.2.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 +6 -0
- package/dist/cjs/commands/index.js +1 -0
- package/dist/cjs/toolbar.js +1 -0
- package/dist/cjs/ui/InlineCommentView.js +1 -1
- package/dist/cjs/utils.js +1 -0
- package/dist/es2019/commands/index.js +1 -1
- package/dist/es2019/toolbar.js +1 -1
- package/dist/es2019/ui/InlineCommentView.js +1 -1
- package/dist/es2019/utils.js +1 -1
- package/dist/esm/commands/index.js +1 -0
- package/dist/esm/toolbar.js +1 -0
- package/dist/esm/ui/InlineCommentView.js +1 -1
- package/dist/esm/utils.js +1 -0
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/toolbar.d.ts +1 -1
- package/dist/types/types.d.ts +10 -0
- package/dist/types/utils.d.ts +1 -1
- package/dist/types-ts4.5/commands/index.d.ts +1 -1
- package/dist/types-ts4.5/toolbar.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +10 -0
- package/dist/types-ts4.5/utils.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 1.2.0
|
|
4
10
|
|
|
5
11
|
### 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;
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -19,6 +19,7 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
|
|
|
19
19
|
return function (state, intl) {
|
|
20
20
|
var isToolbarAbove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
21
21
|
var isCommentOnMediaOn = arguments.length > 3 ? arguments[3] : undefined;
|
|
22
|
+
var _supportedNodes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
22
23
|
var schema = state.schema;
|
|
23
24
|
var selectionValid = (0, _utils2.isSelectionValid)(state, isCommentOnMediaOn);
|
|
24
25
|
var isMediaSelected = isCommentOnMediaOn && (0, _mediaSingle.currentMediaNodeWithPos)(state);
|
|
@@ -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
|
@@ -237,6 +237,7 @@ var getDraftCommandAnalyticsPayload = exports.getDraftCommandAnalyticsPayload =
|
|
|
237
237
|
};
|
|
238
238
|
var isSelectionValid = exports.isSelectionValid = function isSelectionValid(state, isCommentOnMediaOn) {
|
|
239
239
|
var _currentMediaNodeWith;
|
|
240
|
+
var _supportedNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
240
241
|
var selection = state.selection;
|
|
241
242
|
var _ref3 = getPluginState(state) || {},
|
|
242
243
|
disallowOnWhitespace = _ref3.disallowOnWhitespace;
|
|
@@ -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: {
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -8,7 +8,7 @@ import CommentIcon from '@atlaskit/icon/glyph/comment';
|
|
|
8
8
|
import { setInlineCommentDraftState } from './commands';
|
|
9
9
|
import { AnnotationSelectionType, AnnotationTestIds } from './types';
|
|
10
10
|
import { isSelectionValid } from './utils';
|
|
11
|
-
export const buildToolbar = editorAnalyticsAPI => (state, intl, isToolbarAbove = false, isCommentOnMediaOn) => {
|
|
11
|
+
export const buildToolbar = editorAnalyticsAPI => (state, intl, isToolbarAbove = false, isCommentOnMediaOn, _supportedNodes = []) => {
|
|
12
12
|
const {
|
|
13
13
|
schema
|
|
14
14
|
} = state;
|
|
@@ -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
|
@@ -194,7 +194,7 @@ export const getDraftCommandAnalyticsPayload = (drafting, inputMethod) => {
|
|
|
194
194
|
};
|
|
195
195
|
return payload;
|
|
196
196
|
};
|
|
197
|
-
export const isSelectionValid = (state, isCommentOnMediaOn) => {
|
|
197
|
+
export const isSelectionValid = (state, isCommentOnMediaOn, _supportedNodes = []) => {
|
|
198
198
|
var _currentMediaNodeWith;
|
|
199
199
|
const {
|
|
200
200
|
selection
|
|
@@ -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;
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -12,6 +12,7 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
|
|
|
12
12
|
return function (state, intl) {
|
|
13
13
|
var isToolbarAbove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
14
14
|
var isCommentOnMediaOn = arguments.length > 3 ? arguments[3] : undefined;
|
|
15
|
+
var _supportedNodes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
15
16
|
var schema = state.schema;
|
|
16
17
|
var selectionValid = isSelectionValid(state, isCommentOnMediaOn);
|
|
17
18
|
var isMediaSelected = isCommentOnMediaOn && currentMediaNodeWithPos(state);
|
|
@@ -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
|
@@ -210,6 +210,7 @@ export var getDraftCommandAnalyticsPayload = function getDraftCommandAnalyticsPa
|
|
|
210
210
|
};
|
|
211
211
|
export var isSelectionValid = function isSelectionValid(state, isCommentOnMediaOn) {
|
|
212
212
|
var _currentMediaNodeWith;
|
|
213
|
+
var _supportedNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
213
214
|
var selection = state.selection;
|
|
214
215
|
var _ref3 = getPluginState(state) || {},
|
|
215
216
|
disallowOnWhitespace = _ref3.disallowOnWhitespace;
|
|
@@ -6,7 +6,7 @@ import type { AnnotationPlugin, InlineCommentInputMethod, TargetType } from '../
|
|
|
6
6
|
export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
|
|
7
7
|
export declare const closeComponent: () => Command;
|
|
8
8
|
export declare const clearDirtyMark: () => Command;
|
|
9
|
-
export declare const removeInlineCommentNearSelection: (id: string) => Command;
|
|
9
|
+
export declare const removeInlineCommentNearSelection: (id: string, _supportedNodes?: string[]) => Command;
|
|
10
10
|
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
|
|
11
11
|
export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string) => Command;
|
|
12
12
|
export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
|
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, isCommentOnMediaOn?: 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
|
@@ -97,6 +97,16 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
|
|
|
97
97
|
createComponent?: React.ComponentType<InlineCommentCreateComponentProps>;
|
|
98
98
|
viewComponent?: React.ComponentType<InlineCommentViewComponentProps>;
|
|
99
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[];
|
|
100
110
|
};
|
|
101
111
|
export interface AnnotationProviders {
|
|
102
112
|
inlineComment: InlineCommentAnnotationProvider;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const getPluginState: (state: EditorState) => InlineCommentPlugin
|
|
|
28
28
|
* get payload for the open/close analytics event
|
|
29
29
|
*/
|
|
30
30
|
export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: InlineCommentInputMethod) => AnalyticsEventPayloadCallback;
|
|
31
|
-
export declare const isSelectionValid: (state: EditorState, isCommentOnMediaOn?: boolean) => AnnotationSelectionType;
|
|
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
|
|
@@ -6,7 +6,7 @@ import type { AnnotationPlugin, InlineCommentInputMethod, TargetType } from '../
|
|
|
6
6
|
export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
|
|
7
7
|
export declare const closeComponent: () => Command;
|
|
8
8
|
export declare const clearDirtyMark: () => Command;
|
|
9
|
-
export declare const removeInlineCommentNearSelection: (id: string) => Command;
|
|
9
|
+
export declare const removeInlineCommentNearSelection: (id: string, _supportedNodes?: string[]) => Command;
|
|
10
10
|
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
|
|
11
11
|
export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string) => Command;
|
|
12
12
|
export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
|
|
@@ -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, isCommentOnMediaOn?: boolean) => FloatingToolbarConfig | undefined;
|
|
5
|
+
export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (state: EditorState, intl: IntlShape, isToolbarAbove?: boolean, isCommentOnMediaOn?: boolean, _supportedNodes?: string[]) => FloatingToolbarConfig | undefined;
|
|
@@ -97,6 +97,16 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
|
|
|
97
97
|
createComponent?: React.ComponentType<InlineCommentCreateComponentProps>;
|
|
98
98
|
viewComponent?: React.ComponentType<InlineCommentViewComponentProps>;
|
|
99
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[];
|
|
100
110
|
};
|
|
101
111
|
export interface AnnotationProviders {
|
|
102
112
|
inlineComment: InlineCommentAnnotationProvider;
|
|
@@ -28,7 +28,7 @@ export declare const getPluginState: (state: EditorState) => InlineCommentPlugin
|
|
|
28
28
|
* get payload for the open/close analytics event
|
|
29
29
|
*/
|
|
30
30
|
export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: InlineCommentInputMethod) => AnalyticsEventPayloadCallback;
|
|
31
|
-
export declare const isSelectionValid: (state: EditorState, isCommentOnMediaOn?: boolean) => AnnotationSelectionType;
|
|
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
|