@atlaskit/editor-plugin-annotation 1.10.1 → 1.10.2

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.10.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#111460](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/111460)
8
+ [`c7cfc31d4a7b6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c7cfc31d4a7b6) -
9
+ ED-23707 fix issue where comment ui was not triggered on commented node selections.
10
+ - [#110966](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/110966)
11
+ [`31348c335b4b3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/31348c335b4b3) -
12
+ ED-23690 - add inlineNodeTypes property to AnnotationComponentProps
13
+ - Updated dependencies
14
+
3
15
  ## 1.10.1
4
16
 
5
17
  ### Patch Changes
@@ -9,10 +9,11 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _adfSchema = require("@atlaskit/adf-schema");
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
- var _utils = require("@atlaskit/editor-prosemirror/utils");
12
+ var _utils = require("@atlaskit/editor-common/utils");
13
+ var _utils2 = require("@atlaskit/editor-prosemirror/utils");
13
14
  var _commands = require("../commands");
14
15
  var _types = require("../types");
15
- var _utils2 = require("../utils");
16
+ var _utils3 = require("../utils");
16
17
  var _AnnotationViewWrapper = require("./AnnotationViewWrapper");
17
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
19
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -44,18 +45,18 @@ function InlineCommentView(_ref) {
44
45
  dispatch = editorView.dispatch;
45
46
  var CreateComponent = inlineCommentProvider.createComponent,
46
47
  ViewComponent = inlineCommentProvider.viewComponent;
47
- var inlineCommentState = (0, _utils2.getPluginState)(state);
48
+ var inlineCommentState = (0, _utils3.getPluginState)(state);
48
49
  var _ref2 = inlineCommentState || {},
49
50
  bookmark = _ref2.bookmark,
50
51
  selectedAnnotations = _ref2.selectedAnnotations,
51
52
  annotations = _ref2.annotations,
52
53
  isInlineCommentViewClosed = _ref2.isInlineCommentViewClosed;
53
- var annotationsList = (0, _utils2.getAllAnnotations)(editorView.state.doc);
54
- var selection = (0, _utils2.getSelectionPositions)(state, inlineCommentState);
54
+ var annotationsList = (0, _utils3.getAllAnnotations)(editorView.state.doc);
55
+ var selection = (0, _utils3.getSelectionPositions)(state, inlineCommentState);
55
56
  var position = findPosForDOM(selection);
56
57
  var dom;
57
58
  try {
58
- dom = (0, _utils.findDomRefAtPos)(position, editorView.domAtPos.bind(editorView));
59
+ dom = (0, _utils2.findDomRefAtPos)(position, editorView.domAtPos.bind(editorView));
59
60
  } catch (error) {
60
61
  // eslint-disable-next-line no-console
61
62
  console.warn(error);
@@ -78,6 +79,10 @@ function InlineCommentView(_ref) {
78
79
  if (!dom) {
79
80
  return null;
80
81
  }
82
+ var inlineNodeTypes = (0, _utils.getRangeInlineNodeNames)({
83
+ doc: state.doc,
84
+ pos: selection
85
+ });
81
86
 
82
87
  // Create Component
83
88
  if (bookmark) {
@@ -100,7 +105,8 @@ function InlineCommentView(_ref) {
100
105
  onClose: function onClose() {
101
106
  (0, _commands.setInlineCommentDraftState)(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
102
107
  !editorView.hasFocus() && editorView.focus();
103
- }
108
+ },
109
+ inlineNodeTypes: inlineNodeTypes
104
110
  }));
105
111
  }
106
112
 
@@ -142,11 +148,12 @@ function InlineCommentView(_ref) {
142
148
  return /*#__PURE__*/_react.default.createElement(_AnnotationViewWrapper.AnnotationViewWrapper, {
143
149
  "data-editor-popup": "true",
144
150
  "data-testid": _types.AnnotationTestIds.floatingComponent,
145
- key: (0, _utils2.getAnnotationViewKey)(activeAnnotations),
151
+ key: (0, _utils3.getAnnotationViewKey)(activeAnnotations),
146
152
  onViewed: onAnnotationViewed
147
153
  }, /*#__PURE__*/_react.default.createElement(ViewComponent, {
148
154
  annotationsList: annotationsList,
149
155
  annotations: activeAnnotations,
156
+ inlineNodeTypes: inlineNodeTypes,
150
157
  dom: dom,
151
158
  onDelete: function onDelete(id) {
152
159
  return (0, _commands.removeInlineCommentNearSelection)(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch);
package/dist/cjs/utils.js CHANGED
@@ -173,7 +173,15 @@ var findAnnotationsInSelection = exports.findAnnotationsInSelection = function f
173
173
  anchor = selection.anchor;
174
174
  // Only detect annotations on caret selection
175
175
  if (!empty || !doc) {
176
- return [];
176
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
177
+ if (selection instanceof _state.NodeSelection && ['inlineCard', 'emoji', 'date', 'mention', 'status'].includes(selection.node.type.name)) {
178
+ // Inline comments on these nodes are supported -- so we continue to find annotations
179
+ } else {
180
+ return [];
181
+ }
182
+ } else {
183
+ return [];
184
+ }
177
185
  }
178
186
  var node = doc.nodeAt(anchor);
179
187
  var nodeBefore = $anchor.nodeBefore;
@@ -1,6 +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
5
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
5
6
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../commands';
6
7
  import { AnnotationTestIds } from '../types';
@@ -76,6 +77,10 @@ export function InlineCommentView({
76
77
  if (!dom) {
77
78
  return null;
78
79
  }
80
+ const inlineNodeTypes = getRangeInlineNodeNames({
81
+ doc: state.doc,
82
+ pos: selection
83
+ });
79
84
 
80
85
  // Create Component
81
86
  if (bookmark) {
@@ -98,7 +103,8 @@ export function InlineCommentView({
98
103
  onClose: () => {
99
104
  setInlineCommentDraftState(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
100
105
  !editorView.hasFocus() && editorView.focus();
101
- }
106
+ },
107
+ inlineNodeTypes: inlineNodeTypes
102
108
  }));
103
109
  }
104
110
 
@@ -145,6 +151,7 @@ export function InlineCommentView({
145
151
  }, /*#__PURE__*/React.createElement(ViewComponent, {
146
152
  annotationsList: annotationsList,
147
153
  annotations: activeAnnotations,
154
+ inlineNodeTypes: inlineNodeTypes,
148
155
  dom: dom,
149
156
  onDelete: id => removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch),
150
157
  onResolve: id => updateInlineCommentResolvedState(editorAnalyticsAPI)({
@@ -136,7 +136,15 @@ export const findAnnotationsInSelection = (selection, doc, isCommentsOnMediaMedi
136
136
  } = selection;
137
137
  // Only detect annotations on caret selection
138
138
  if (!empty || !doc) {
139
- return [];
139
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
140
+ if (selection instanceof NodeSelection && ['inlineCard', 'emoji', 'date', 'mention', 'status'].includes(selection.node.type.name)) {
141
+ // Inline comments on these nodes are supported -- so we continue to find annotations
142
+ } else {
143
+ return [];
144
+ }
145
+ } else {
146
+ return [];
147
+ }
140
148
  }
141
149
  const node = doc.nodeAt(anchor);
142
150
  const nodeBefore = $anchor.nodeBefore;
@@ -4,6 +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
8
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
8
9
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../commands';
9
10
  import { AnnotationTestIds } from '../types';
@@ -71,6 +72,10 @@ export function InlineCommentView(_ref) {
71
72
  if (!dom) {
72
73
  return null;
73
74
  }
75
+ var inlineNodeTypes = getRangeInlineNodeNames({
76
+ doc: state.doc,
77
+ pos: selection
78
+ });
74
79
 
75
80
  // Create Component
76
81
  if (bookmark) {
@@ -93,7 +98,8 @@ export function InlineCommentView(_ref) {
93
98
  onClose: function onClose() {
94
99
  setInlineCommentDraftState(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
95
100
  !editorView.hasFocus() && editorView.focus();
96
- }
101
+ },
102
+ inlineNodeTypes: inlineNodeTypes
97
103
  }));
98
104
  }
99
105
 
@@ -140,6 +146,7 @@ export function InlineCommentView(_ref) {
140
146
  }, /*#__PURE__*/React.createElement(ViewComponent, {
141
147
  annotationsList: annotationsList,
142
148
  annotations: activeAnnotations,
149
+ inlineNodeTypes: inlineNodeTypes,
143
150
  dom: dom,
144
151
  onDelete: function onDelete(id) {
145
152
  return removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch);
package/dist/esm/utils.js CHANGED
@@ -146,7 +146,15 @@ export var findAnnotationsInSelection = function findAnnotationsInSelection(sele
146
146
  anchor = selection.anchor;
147
147
  // Only detect annotations on caret selection
148
148
  if (!empty || !doc) {
149
- return [];
149
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
150
+ if (selection instanceof NodeSelection && ['inlineCard', 'emoji', 'date', 'mention', 'status'].includes(selection.node.type.name)) {
151
+ // Inline comments on these nodes are supported -- so we continue to find annotations
152
+ } else {
153
+ return [];
154
+ }
155
+ } else {
156
+ return [];
157
+ }
150
158
  }
151
159
  var node = doc.nodeAt(anchor);
152
160
  var nodeBefore = $anchor.nodeBefore;
@@ -49,6 +49,10 @@ declare const _default: {
49
49
  to: number;
50
50
  mark: import("prosemirror-model").Mark;
51
51
  }) => boolean;
52
+ addInlineCommentNodeMark: (props: {
53
+ pos: number;
54
+ mark: import("prosemirror-model").Mark;
55
+ }) => boolean;
52
56
  isRemoteReplaceDocumentTransaction: (tr: Transaction) => boolean;
53
57
  };
54
58
  }, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>];
@@ -115,6 +119,10 @@ declare const _default: {
115
119
  to: number;
116
120
  mark: import("prosemirror-model").Mark;
117
121
  }) => boolean;
122
+ addInlineCommentNodeMark: (props: {
123
+ pos: number;
124
+ mark: import("prosemirror-model").Mark;
125
+ }) => boolean;
118
126
  isRemoteReplaceDocumentTransaction: (tr: Transaction) => boolean;
119
127
  };
120
128
  }, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>];
@@ -61,6 +61,8 @@ 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;
64
66
  };
65
67
  export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
66
68
  /**
@@ -60,6 +60,10 @@ declare const _default: {
60
60
  to: number;
61
61
  mark: import("prosemirror-model").Mark;
62
62
  }) => boolean;
63
+ addInlineCommentNodeMark: (props: {
64
+ pos: number;
65
+ mark: import("prosemirror-model").Mark;
66
+ }) => boolean;
63
67
  isRemoteReplaceDocumentTransaction: (tr: Transaction) => boolean;
64
68
  };
65
69
  }, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>
@@ -139,6 +143,10 @@ declare const _default: {
139
143
  to: number;
140
144
  mark: import("prosemirror-model").Mark;
141
145
  }) => boolean;
146
+ addInlineCommentNodeMark: (props: {
147
+ pos: number;
148
+ mark: import("prosemirror-model").Mark;
149
+ }) => boolean;
142
150
  isRemoteReplaceDocumentTransaction: (tr: Transaction) => boolean;
143
151
  };
144
152
  }, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>
@@ -61,6 +61,8 @@ 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;
64
66
  };
65
67
  export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
66
68
  /**
package/package.json CHANGED
@@ -1,106 +1,86 @@
1
1
  {
2
- "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "1.10.1",
4
- "description": "Annotation plugin for @atlaskit/editor-core",
5
- "author": "Atlassian Pty Ltd",
6
- "license": "Apache-2.0",
7
- "publishConfig": {
8
- "registry": "https://registry.npmjs.org/"
9
- },
10
- "atlassian": {
11
- "team": "Editor: AI",
12
- "singleton": true,
13
- "releaseModel": "continuous",
14
- "runReact18": false
15
- },
16
- "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
17
- "main": "dist/cjs/index.js",
18
- "module": "dist/esm/index.js",
19
- "module:es2019": "dist/es2019/index.js",
20
- "types": "dist/types/index.d.ts",
21
- "typesVersions": {
22
- ">=4.5 <4.9": {
23
- "*": [
24
- "dist/types-ts4.5/*",
25
- "dist/types-ts4.5/index.d.ts"
26
- ]
27
- }
28
- },
29
- "sideEffects": false,
30
- "atlaskit:src": "src/index.ts",
31
- "af:exports": {
32
- ".": "./src/index.ts"
33
- },
34
- "dependencies": {
35
- "@atlaskit/adf-schema": "^36.10.7",
36
- "@atlaskit/editor-common": "^82.3.0",
37
- "@atlaskit/editor-plugin-analytics": "^1.2.0",
38
- "@atlaskit/editor-plugin-editor-viewmode": "^1.1.0",
39
- "@atlaskit/editor-plugin-feature-flags": "^1.1.0",
40
- "@atlaskit/editor-prosemirror": "4.0.1",
41
- "@atlaskit/icon": "^22.3.0",
42
- "@atlaskit/platform-feature-flags": "^0.2.0",
43
- "@babel/runtime": "^7.0.0"
44
- },
45
- "peerDependencies": {
46
- "react": "^16.8.0"
47
- },
48
- "devDependencies": {
49
- "@af/integration-testing": "*",
50
- "@af/visual-regression": "*",
51
- "@atlaskit/ssr": "*",
52
- "@atlaskit/visual-regression": "*",
53
- "@atlassian/feature-flags-test-utils": "^0.2.0",
54
- "@testing-library/react": "^12.1.5",
55
- "react-dom": "^16.8.0",
56
- "typescript": "~5.4.2",
57
- "wait-for-expect": "^1.2.0"
58
- },
59
- "techstack": {
60
- "@atlassian/frontend": {
61
- "import-structure": [
62
- "atlassian-conventions"
63
- ],
64
- "circular-dependencies": [
65
- "file-and-folder-level"
66
- ]
67
- },
68
- "@repo/internal": {
69
- "dom-events": "use-bind-event-listener",
70
- "analytics": [
71
- "analytics-next"
72
- ],
73
- "design-tokens": [
74
- "color"
75
- ],
76
- "theming": [
77
- "react-context"
78
- ],
79
- "ui-components": [
80
- "lite-mode"
81
- ],
82
- "deprecation": "no-deprecated-imports",
83
- "styling": [
84
- "emotion",
85
- "emotion"
86
- ],
87
- "imports": [
88
- "import-no-extraneous-disable-for-examples-and-docs"
89
- ]
90
- }
91
- },
92
- "platform-feature-flags": {
93
- "platform.editor.enable-selection-toolbar_ucdwd": {
94
- "type": "boolean"
95
- },
96
- "platform.editor.allow-inline-comments-for-inline-nodes": {
97
- "type": "boolean"
98
- },
99
- "platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz": {
100
- "type": "boolean"
101
- },
102
- "platform.editor.comments-on-media.bug.preserve-draft_i3vqb": {
103
- "type": "boolean"
104
- }
105
- }
106
- }
2
+ "name": "@atlaskit/editor-plugin-annotation",
3
+ "version": "1.10.2",
4
+ "description": "Annotation plugin for @atlaskit/editor-core",
5
+ "author": "Atlassian Pty Ltd",
6
+ "license": "Apache-2.0",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/"
9
+ },
10
+ "atlassian": {
11
+ "team": "Editor: AI",
12
+ "singleton": true,
13
+ "releaseModel": "continuous",
14
+ "runReact18": false
15
+ },
16
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
17
+ "main": "dist/cjs/index.js",
18
+ "module": "dist/esm/index.js",
19
+ "module:es2019": "dist/es2019/index.js",
20
+ "types": "dist/types/index.d.ts",
21
+ "typesVersions": {
22
+ ">=4.5 <4.9": {
23
+ "*": ["dist/types-ts4.5/*", "dist/types-ts4.5/index.d.ts"]
24
+ }
25
+ },
26
+ "sideEffects": false,
27
+ "atlaskit:src": "src/index.ts",
28
+ "af:exports": {
29
+ ".": "./src/index.ts"
30
+ },
31
+ "dependencies": {
32
+ "@atlaskit/adf-schema": "^36.10.7",
33
+ "@atlaskit/editor-common": "^82.6.0",
34
+ "@atlaskit/editor-plugin-analytics": "^1.2.0",
35
+ "@atlaskit/editor-plugin-editor-viewmode": "^1.2.0",
36
+ "@atlaskit/editor-plugin-feature-flags": "^1.1.0",
37
+ "@atlaskit/editor-prosemirror": "4.0.1",
38
+ "@atlaskit/icon": "^22.3.0",
39
+ "@atlaskit/platform-feature-flags": "^0.2.0",
40
+ "@babel/runtime": "^7.0.0"
41
+ },
42
+ "peerDependencies": {
43
+ "react": "^16.8.0"
44
+ },
45
+ "devDependencies": {
46
+ "@af/integration-testing": "*",
47
+ "@af/visual-regression": "*",
48
+ "@atlaskit/ssr": "*",
49
+ "@atlaskit/visual-regression": "*",
50
+ "@atlassian/feature-flags-test-utils": "^0.2.0",
51
+ "@testing-library/react": "^12.1.5",
52
+ "react-dom": "^16.8.0",
53
+ "typescript": "~5.4.2",
54
+ "wait-for-expect": "^1.2.0"
55
+ },
56
+ "techstack": {
57
+ "@atlassian/frontend": {
58
+ "import-structure": ["atlassian-conventions"],
59
+ "circular-dependencies": ["file-and-folder-level"]
60
+ },
61
+ "@repo/internal": {
62
+ "dom-events": "use-bind-event-listener",
63
+ "analytics": ["analytics-next"],
64
+ "design-tokens": ["color"],
65
+ "theming": ["react-context"],
66
+ "ui-components": ["lite-mode"],
67
+ "deprecation": "no-deprecated-imports",
68
+ "styling": ["emotion", "emotion"],
69
+ "imports": ["import-no-extraneous-disable-for-examples-and-docs"]
70
+ }
71
+ },
72
+ "platform-feature-flags": {
73
+ "platform.editor.enable-selection-toolbar_ucdwd": {
74
+ "type": "boolean"
75
+ },
76
+ "platform.editor.allow-inline-comments-for-inline-nodes": {
77
+ "type": "boolean"
78
+ },
79
+ "platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz": {
80
+ "type": "boolean"
81
+ },
82
+ "platform.editor.comments-on-media.bug.preserve-draft_i3vqb": {
83
+ "type": "boolean"
84
+ }
85
+ }
86
+ }