@atlaskit/editor-plugin-annotation 1.10.4 → 1.11.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 1.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#112275](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/112275)
8
+ [`6f3058e0347a3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6f3058e0347a3) -
9
+ ED-23734 - add `getInlineNodeTypes` function to `InlineCommentViewComponentProps`
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 1.10.4
4
16
 
5
17
  ### Patch Changes
@@ -79,16 +79,16 @@ function InlineCommentView(_ref) {
79
79
  if (!dom) {
80
80
  return null;
81
81
  }
82
- var inlineNodeTypes = (0, _utils.getRangeInlineNodeNames)({
83
- doc: state.doc,
84
- pos: selection
85
- });
86
82
 
87
83
  // Create Component
88
84
  if (bookmark) {
89
85
  if (!CreateComponent) {
90
86
  return null;
91
87
  }
88
+ var inlineNodeTypes = (0, _utils.getRangeInlineNodeNames)({
89
+ doc: state.doc,
90
+ pos: selection
91
+ });
92
92
 
93
93
  //getting all text between bookmarked positions
94
94
  var textSelection = state.doc.textBetween(selection.from, selection.to);
@@ -145,6 +145,13 @@ function InlineCommentView(_ref) {
145
145
  if (isInlineCommentViewClosed || !selectedAnnotations) {
146
146
  return null;
147
147
  }
148
+
149
+ // For view mode, the finding of inline node types is a bit more complex,
150
+ // that's why we will not provide it as a `inlineNodeTypes` props to the view component,
151
+ // to speed up the rendering process.
152
+ var getInlineNodeTypes = function getInlineNodeTypes(annotationId) {
153
+ return (0, _utils.getAnnotationInlineNodeTypes)(editorView.state, annotationId);
154
+ };
148
155
  return /*#__PURE__*/_react.default.createElement(_AnnotationViewWrapper.AnnotationViewWrapper, {
149
156
  "data-editor-popup": "true",
150
157
  "data-testid": _types.AnnotationTestIds.floatingComponent,
@@ -153,7 +160,7 @@ function InlineCommentView(_ref) {
153
160
  }, /*#__PURE__*/_react.default.createElement(ViewComponent, {
154
161
  annotationsList: annotationsList,
155
162
  annotations: activeAnnotations,
156
- inlineNodeTypes: inlineNodeTypes,
163
+ getInlineNodeTypes: getInlineNodeTypes,
157
164
  dom: dom,
158
165
  onDelete: function onDelete(id) {
159
166
  return (0, _commands.removeInlineCommentNearSelection)(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch);
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { AnnotationTypes } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, CONTENT_COMPONENT, EVENT_TYPE, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
4
- import { getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
4
+ import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
5
5
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../commands';
7
7
  import { AnnotationTestIds } from '../types';
@@ -77,16 +77,16 @@ export function InlineCommentView({
77
77
  if (!dom) {
78
78
  return null;
79
79
  }
80
- const inlineNodeTypes = getRangeInlineNodeNames({
81
- doc: state.doc,
82
- pos: selection
83
- });
84
80
 
85
81
  // Create Component
86
82
  if (bookmark) {
87
83
  if (!CreateComponent) {
88
84
  return null;
89
85
  }
86
+ const inlineNodeTypes = getRangeInlineNodeNames({
87
+ doc: state.doc,
88
+ pos: selection
89
+ });
90
90
 
91
91
  //getting all text between bookmarked positions
92
92
  const textSelection = state.doc.textBetween(selection.from, selection.to);
@@ -143,6 +143,11 @@ export function InlineCommentView({
143
143
  if (isInlineCommentViewClosed || !selectedAnnotations) {
144
144
  return null;
145
145
  }
146
+
147
+ // For view mode, the finding of inline node types is a bit more complex,
148
+ // that's why we will not provide it as a `inlineNodeTypes` props to the view component,
149
+ // to speed up the rendering process.
150
+ const getInlineNodeTypes = annotationId => getAnnotationInlineNodeTypes(editorView.state, annotationId);
146
151
  return /*#__PURE__*/React.createElement(AnnotationViewWrapper, {
147
152
  "data-editor-popup": "true",
148
153
  "data-testid": AnnotationTestIds.floatingComponent,
@@ -151,7 +156,7 @@ export function InlineCommentView({
151
156
  }, /*#__PURE__*/React.createElement(ViewComponent, {
152
157
  annotationsList: annotationsList,
153
158
  annotations: activeAnnotations,
154
- inlineNodeTypes: inlineNodeTypes,
159
+ getInlineNodeTypes: getInlineNodeTypes,
155
160
  dom: dom,
156
161
  onDelete: id => removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch),
157
162
  onResolve: id => updateInlineCommentResolvedState(editorAnalyticsAPI)({
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import React from 'react';
5
5
  import { AnnotationTypes } from '@atlaskit/adf-schema';
6
6
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, CONTENT_COMPONENT, EVENT_TYPE, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
7
- import { getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
7
+ import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
8
8
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../commands';
10
10
  import { AnnotationTestIds } from '../types';
@@ -72,16 +72,16 @@ export function InlineCommentView(_ref) {
72
72
  if (!dom) {
73
73
  return null;
74
74
  }
75
- var inlineNodeTypes = getRangeInlineNodeNames({
76
- doc: state.doc,
77
- pos: selection
78
- });
79
75
 
80
76
  // Create Component
81
77
  if (bookmark) {
82
78
  if (!CreateComponent) {
83
79
  return null;
84
80
  }
81
+ var inlineNodeTypes = getRangeInlineNodeNames({
82
+ doc: state.doc,
83
+ pos: selection
84
+ });
85
85
 
86
86
  //getting all text between bookmarked positions
87
87
  var textSelection = state.doc.textBetween(selection.from, selection.to);
@@ -138,6 +138,13 @@ export function InlineCommentView(_ref) {
138
138
  if (isInlineCommentViewClosed || !selectedAnnotations) {
139
139
  return null;
140
140
  }
141
+
142
+ // For view mode, the finding of inline node types is a bit more complex,
143
+ // that's why we will not provide it as a `inlineNodeTypes` props to the view component,
144
+ // to speed up the rendering process.
145
+ var getInlineNodeTypes = function getInlineNodeTypes(annotationId) {
146
+ return getAnnotationInlineNodeTypes(editorView.state, annotationId);
147
+ };
141
148
  return /*#__PURE__*/React.createElement(AnnotationViewWrapper, {
142
149
  "data-editor-popup": "true",
143
150
  "data-testid": AnnotationTestIds.floatingComponent,
@@ -146,7 +153,7 @@ export function InlineCommentView(_ref) {
146
153
  }, /*#__PURE__*/React.createElement(ViewComponent, {
147
154
  annotationsList: annotationsList,
148
155
  annotations: activeAnnotations,
149
- inlineNodeTypes: inlineNodeTypes,
156
+ getInlineNodeTypes: getInlineNodeTypes,
150
157
  dom: dom,
151
158
  onDelete: function onDelete(id) {
152
159
  return removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch);
@@ -36,7 +36,18 @@ declare const _default: {
36
36
  sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
37
37
  }, import("@atlaskit/editor-common/types").FeatureFlags>>];
38
38
  actions: EditorAnalyticsAPI;
39
- }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>];
39
+ }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorViewMode", {
40
+ sharedState: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginState | null;
41
+ dependencies: [];
42
+ pluginConfiguration?: {
43
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
44
+ } | undefined;
45
+ commands: {
46
+ updateViewMode: (mode: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode) => import("@atlaskit/editor-common/types").EditorCommand;
47
+ };
48
+ }, {
49
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
50
+ } | undefined>>];
40
51
  sharedState: import("@atlaskit/editor-plugin-collab-edit").CollabEditPluginSharedState;
41
52
  actions: {
42
53
  getAvatarColor: (str: string) => {
@@ -108,7 +119,18 @@ declare const _default: {
108
119
  sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
109
120
  }, import("@atlaskit/editor-common/types").FeatureFlags>>];
110
121
  actions: EditorAnalyticsAPI;
111
- }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>];
122
+ }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorViewMode", {
123
+ sharedState: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginState | null;
124
+ dependencies: [];
125
+ pluginConfiguration?: {
126
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
127
+ } | undefined;
128
+ commands: {
129
+ updateViewMode: (mode: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode) => import("@atlaskit/editor-common/types").EditorCommand;
130
+ };
131
+ }, {
132
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
133
+ } | undefined>>];
112
134
  sharedState: import("@atlaskit/editor-plugin-collab-edit").CollabEditPluginSharedState;
113
135
  actions: {
114
136
  getAvatarColor: (str: string) => {
@@ -61,14 +61,14 @@ type AnnotationComponentProps = {
61
61
  * Indicates that a draft comment was discarded/cancelled
62
62
  */
63
63
  onClose?: () => void;
64
- /** List of inline node types, which are wrapped by the annotation. */
65
- inlineNodeTypes: string[] | undefined;
66
64
  };
67
65
  export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
68
66
  /**
69
67
  * Creates an annotation mark in the document with the given id.
70
68
  */
71
69
  onCreate: (id: string) => void;
70
+ /** List of inline node types, which are wrapped by the annotation. */
71
+ inlineNodeTypes: string[] | undefined;
72
72
  };
73
73
  export type InlineCommentViewComponentProps = AnnotationComponentProps & {
74
74
  /**
@@ -88,6 +88,16 @@ export type InlineCommentViewComponentProps = AnnotationComponentProps & {
88
88
  * Ordered list of annotation ids as shown in the document
89
89
  */
90
90
  annotationsList?: string[];
91
+ /**
92
+ * Return a list of inline node types, which are wrapped by the annotation,
93
+ * for annotation with given ID.
94
+ *
95
+ * The `undefined` will be returned if `platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz` is off.
96
+ *
97
+ * @todo: Do not forget to remove `undefined` when the
98
+ * `platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz` is removed.
99
+ */
100
+ getInlineNodeTypes: (annotationId: string) => string[] | undefined;
91
101
  };
92
102
  export interface AnnotationState<Type, State> {
93
103
  annotationType: Type;
@@ -46,7 +46,20 @@ declare const _default: {
46
46
  }, import("@atlaskit/editor-common/types").FeatureFlags>>
47
47
  ];
48
48
  actions: EditorAnalyticsAPI;
49
- }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>
49
+ }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>,
50
+ import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorViewMode", {
51
+ sharedState: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginState | null;
52
+ dependencies: [
53
+ ];
54
+ pluginConfiguration?: {
55
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
56
+ } | undefined;
57
+ commands: {
58
+ updateViewMode: (mode: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode) => import("@atlaskit/editor-common/types").EditorCommand;
59
+ };
60
+ }, {
61
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
62
+ } | undefined>>
50
63
  ];
51
64
  sharedState: import("@atlaskit/editor-plugin-collab-edit").CollabEditPluginSharedState;
52
65
  actions: {
@@ -133,7 +146,20 @@ declare const _default: {
133
146
  }, import("@atlaskit/editor-common/types").FeatureFlags>>
134
147
  ];
135
148
  actions: EditorAnalyticsAPI;
136
- }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>
149
+ }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>,
150
+ import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorViewMode", {
151
+ sharedState: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginState | null;
152
+ dependencies: [
153
+ ];
154
+ pluginConfiguration?: {
155
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
156
+ } | undefined;
157
+ commands: {
158
+ updateViewMode: (mode: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode) => import("@atlaskit/editor-common/types").EditorCommand;
159
+ };
160
+ }, {
161
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
162
+ } | undefined>>
137
163
  ];
138
164
  sharedState: import("@atlaskit/editor-plugin-collab-edit").CollabEditPluginSharedState;
139
165
  actions: {
@@ -61,14 +61,14 @@ type AnnotationComponentProps = {
61
61
  * Indicates that a draft comment was discarded/cancelled
62
62
  */
63
63
  onClose?: () => void;
64
- /** List of inline node types, which are wrapped by the annotation. */
65
- inlineNodeTypes: string[] | undefined;
66
64
  };
67
65
  export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
68
66
  /**
69
67
  * Creates an annotation mark in the document with the given id.
70
68
  */
71
69
  onCreate: (id: string) => void;
70
+ /** List of inline node types, which are wrapped by the annotation. */
71
+ inlineNodeTypes: string[] | undefined;
72
72
  };
73
73
  export type InlineCommentViewComponentProps = AnnotationComponentProps & {
74
74
  /**
@@ -88,6 +88,16 @@ export type InlineCommentViewComponentProps = AnnotationComponentProps & {
88
88
  * Ordered list of annotation ids as shown in the document
89
89
  */
90
90
  annotationsList?: string[];
91
+ /**
92
+ * Return a list of inline node types, which are wrapped by the annotation,
93
+ * for annotation with given ID.
94
+ *
95
+ * The `undefined` will be returned if `platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz` is off.
96
+ *
97
+ * @todo: Do not forget to remove `undefined` when the
98
+ * `platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz` is removed.
99
+ */
100
+ getInlineNodeTypes: (annotationId: string) => string[] | undefined;
91
101
  };
92
102
  export interface AnnotationState<Type, State> {
93
103
  annotationType: Type;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "1.10.4",
3
+ "version": "1.11.0",
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": "^36.10.7",
36
- "@atlaskit/editor-common": "^82.9.0",
36
+ "@atlaskit/editor-common": "^82.11.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^1.2.0",
38
38
  "@atlaskit/editor-plugin-editor-viewmode-effects": "^1.0.0",
39
39
  "@atlaskit/editor-plugin-feature-flags": "^1.1.0",