@atlaskit/editor-plugin-annotation 2.8.2 → 2.8.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
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.InlineCommentView = InlineCommentView;
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _react =
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
11
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
13
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
@@ -19,6 +20,8 @@ var _editorCommands = require("../editor-commands");
|
|
|
19
20
|
var _utils3 = require("../pm-plugins/utils");
|
|
20
21
|
var _types = require("../types");
|
|
21
22
|
var _AnnotationViewWrapper = require("./AnnotationViewWrapper");
|
|
23
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
24
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
25
|
var findPosForDOM = function findPosForDOM(sel) {
|
|
23
26
|
var $from = sel.$from,
|
|
24
27
|
from = sel.from;
|
|
@@ -79,6 +82,7 @@ function InlineCommentView(_ref3) {
|
|
|
79
82
|
var inlineCommentProvider = providers.inlineComment;
|
|
80
83
|
var state = editorView.state,
|
|
81
84
|
dispatch = editorView.dispatch;
|
|
85
|
+
var lastSelectedAnnotationId = (0, _react.useRef)();
|
|
82
86
|
var CreateComponent = inlineCommentProvider.createComponent,
|
|
83
87
|
ViewComponent = inlineCommentProvider.viewComponent;
|
|
84
88
|
var _useInlineCommentView = useInlineCommentViewPluginState({
|
|
@@ -131,9 +135,17 @@ function InlineCommentView(_ref3) {
|
|
|
131
135
|
|
|
132
136
|
// Create Component
|
|
133
137
|
if (bookmark) {
|
|
138
|
+
var _selectedAnnotations$;
|
|
134
139
|
if (!CreateComponent) {
|
|
135
140
|
return null;
|
|
136
141
|
}
|
|
142
|
+
var currentlySelectedAnnotation = selectedAnnotations === null || selectedAnnotations === void 0 || (_selectedAnnotations$ = selectedAnnotations[0]) === null || _selectedAnnotations$ === void 0 ? void 0 : _selectedAnnotations$.id;
|
|
143
|
+
var isAnnotationSelectionChanged = currentlySelectedAnnotation !== lastSelectedAnnotationId.current;
|
|
144
|
+
|
|
145
|
+
// Update the last selected annotation ID if the selection was updated
|
|
146
|
+
if (isAnnotationSelectionChanged) {
|
|
147
|
+
lastSelectedAnnotationId.current = currentlySelectedAnnotation;
|
|
148
|
+
}
|
|
137
149
|
var inlineNodeTypes = (0, _utils.getRangeInlineNodeNames)({
|
|
138
150
|
doc: state.doc,
|
|
139
151
|
pos: selection
|
|
@@ -147,6 +159,7 @@ function InlineCommentView(_ref3) {
|
|
|
147
159
|
}, /*#__PURE__*/_react.default.createElement(CreateComponent, {
|
|
148
160
|
dom: dom,
|
|
149
161
|
textSelection: textSelection,
|
|
162
|
+
wasNewAnnotationSelected: !!currentlySelectedAnnotation && isAnnotationSelectionChanged,
|
|
150
163
|
onCreate: function onCreate(id) {
|
|
151
164
|
if (!(0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
|
|
152
165
|
var createAnnotationResult = (0, _editorCommands.createAnnotation)(editorAnalyticsAPI, editorAPI)(id, _adfSchema.AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useRef } 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
4
|
import { sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
@@ -78,6 +78,7 @@ export function InlineCommentView({
|
|
|
78
78
|
state,
|
|
79
79
|
dispatch
|
|
80
80
|
} = editorView;
|
|
81
|
+
const lastSelectedAnnotationId = useRef();
|
|
81
82
|
const {
|
|
82
83
|
createComponent: CreateComponent,
|
|
83
84
|
viewComponent: ViewComponent
|
|
@@ -133,9 +134,17 @@ export function InlineCommentView({
|
|
|
133
134
|
|
|
134
135
|
// Create Component
|
|
135
136
|
if (bookmark) {
|
|
137
|
+
var _selectedAnnotations$;
|
|
136
138
|
if (!CreateComponent) {
|
|
137
139
|
return null;
|
|
138
140
|
}
|
|
141
|
+
const currentlySelectedAnnotation = selectedAnnotations === null || selectedAnnotations === void 0 ? void 0 : (_selectedAnnotations$ = selectedAnnotations[0]) === null || _selectedAnnotations$ === void 0 ? void 0 : _selectedAnnotations$.id;
|
|
142
|
+
const isAnnotationSelectionChanged = currentlySelectedAnnotation !== lastSelectedAnnotationId.current;
|
|
143
|
+
|
|
144
|
+
// Update the last selected annotation ID if the selection was updated
|
|
145
|
+
if (isAnnotationSelectionChanged) {
|
|
146
|
+
lastSelectedAnnotationId.current = currentlySelectedAnnotation;
|
|
147
|
+
}
|
|
139
148
|
const inlineNodeTypes = getRangeInlineNodeNames({
|
|
140
149
|
doc: state.doc,
|
|
141
150
|
pos: selection
|
|
@@ -149,6 +158,7 @@ export function InlineCommentView({
|
|
|
149
158
|
}, /*#__PURE__*/React.createElement(CreateComponent, {
|
|
150
159
|
dom: dom,
|
|
151
160
|
textSelection: textSelection,
|
|
161
|
+
wasNewAnnotationSelected: !!currentlySelectedAnnotation && isAnnotationSelectionChanged,
|
|
152
162
|
onCreate: id => {
|
|
153
163
|
if (!fg('platform_editor_comments_api_manager')) {
|
|
154
164
|
const createAnnotationResult = createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
3
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, CONTENT_COMPONENT, EVENT_TYPE, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
@@ -72,6 +72,7 @@ export function InlineCommentView(_ref3) {
|
|
|
72
72
|
var inlineCommentProvider = providers.inlineComment;
|
|
73
73
|
var state = editorView.state,
|
|
74
74
|
dispatch = editorView.dispatch;
|
|
75
|
+
var lastSelectedAnnotationId = useRef();
|
|
75
76
|
var CreateComponent = inlineCommentProvider.createComponent,
|
|
76
77
|
ViewComponent = inlineCommentProvider.viewComponent;
|
|
77
78
|
var _useInlineCommentView = useInlineCommentViewPluginState({
|
|
@@ -124,9 +125,17 @@ export function InlineCommentView(_ref3) {
|
|
|
124
125
|
|
|
125
126
|
// Create Component
|
|
126
127
|
if (bookmark) {
|
|
128
|
+
var _selectedAnnotations$;
|
|
127
129
|
if (!CreateComponent) {
|
|
128
130
|
return null;
|
|
129
131
|
}
|
|
132
|
+
var currentlySelectedAnnotation = selectedAnnotations === null || selectedAnnotations === void 0 || (_selectedAnnotations$ = selectedAnnotations[0]) === null || _selectedAnnotations$ === void 0 ? void 0 : _selectedAnnotations$.id;
|
|
133
|
+
var isAnnotationSelectionChanged = currentlySelectedAnnotation !== lastSelectedAnnotationId.current;
|
|
134
|
+
|
|
135
|
+
// Update the last selected annotation ID if the selection was updated
|
|
136
|
+
if (isAnnotationSelectionChanged) {
|
|
137
|
+
lastSelectedAnnotationId.current = currentlySelectedAnnotation;
|
|
138
|
+
}
|
|
130
139
|
var inlineNodeTypes = getRangeInlineNodeNames({
|
|
131
140
|
doc: state.doc,
|
|
132
141
|
pos: selection
|
|
@@ -140,6 +149,7 @@ export function InlineCommentView(_ref3) {
|
|
|
140
149
|
}, /*#__PURE__*/React.createElement(CreateComponent, {
|
|
141
150
|
dom: dom,
|
|
142
151
|
textSelection: textSelection,
|
|
152
|
+
wasNewAnnotationSelected: !!currentlySelectedAnnotation && isAnnotationSelectionChanged,
|
|
143
153
|
onCreate: function onCreate(id) {
|
|
144
154
|
if (!fg('platform_editor_comments_api_manager')) {
|
|
145
155
|
var createAnnotationResult = createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
|
|
@@ -45,6 +45,7 @@ export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
|
|
|
45
45
|
* Indicates whether we're opening the media comment box from the media toolbar so we can scroll the media into view
|
|
46
46
|
*/
|
|
47
47
|
isOpeningMediaCommentFromToolbar?: boolean;
|
|
48
|
+
wasNewAnnotationSelected?: boolean;
|
|
48
49
|
};
|
|
49
50
|
export type InlineCommentViewComponentProps = AnnotationComponentProps & {
|
|
50
51
|
/**
|
|
@@ -45,6 +45,7 @@ export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
|
|
|
45
45
|
* Indicates whether we're opening the media comment box from the media toolbar so we can scroll the media into view
|
|
46
46
|
*/
|
|
47
47
|
isOpeningMediaCommentFromToolbar?: boolean;
|
|
48
|
+
wasNewAnnotationSelected?: boolean;
|
|
48
49
|
};
|
|
49
50
|
export type InlineCommentViewComponentProps = AnnotationComponentProps & {
|
|
50
51
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.3",
|
|
4
4
|
"description": "Annotation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
35
35
|
"@atlaskit/analytics-next": "^11.0.0",
|
|
36
|
-
"@atlaskit/editor-common": "^105.
|
|
36
|
+
"@atlaskit/editor-common": "^105.10.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^2.3.0",
|
|
38
38
|
"@atlaskit/editor-plugin-connectivity": "^2.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode-effects": "^2.0.0",
|
|
40
40
|
"@atlaskit/editor-plugin-feature-flags": "^1.4.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
42
|
-
"@atlaskit/icon": "^26.
|
|
42
|
+
"@atlaskit/icon": "^26.3.0",
|
|
43
43
|
"@atlaskit/onboarding": "^14.1.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
45
|
+
"@atlaskit/tmp-editor-statsig": "^5.0.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|