@atlaskit/editor-plugin-annotation 1.9.0 → 1.9.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 +10 -0
- package/dist/cjs/pm-plugins/inline-comment.js +8 -1
- package/dist/cjs/pm-plugins/plugin-factory.js +2 -2
- package/dist/cjs/utils.js +11 -3
- package/dist/es2019/pm-plugins/inline-comment.js +8 -1
- package/dist/es2019/pm-plugins/plugin-factory.js +2 -2
- package/dist/es2019/utils.js +9 -3
- package/dist/esm/pm-plugins/inline-comment.js +8 -1
- package/dist/esm/pm-plugins/plugin-factory.js +2 -2
- package/dist/esm/utils.js +11 -3
- package/dist/types/utils.d.ts +1 -1
- package/dist/types-ts4.5/utils.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 1.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#97803](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97803)
|
|
8
|
+
[`4c1023ffb3d8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4c1023ffb3d8) -
|
|
9
|
+
[ED-23094] Ignore annotations on mediaInline node, including highlight styling,
|
|
10
|
+
event(onMouseEnter, onClick) listeners, update active annotations when the node is selected or
|
|
11
|
+
the cursor is right after the node
|
|
12
|
+
|
|
3
13
|
## 1.9.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -220,11 +220,18 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
220
220
|
annotations = _ref5.annotations,
|
|
221
221
|
selectedAnnotations = _ref5.selectedAnnotations,
|
|
222
222
|
isVisible = _ref5.isVisible,
|
|
223
|
-
isInlineCommentViewClosed = _ref5.isInlineCommentViewClosed
|
|
223
|
+
isInlineCommentViewClosed = _ref5.isInlineCommentViewClosed,
|
|
224
|
+
featureFlagsPluginState = _ref5.featureFlagsPluginState;
|
|
224
225
|
var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : _view.DecorationSet.empty;
|
|
225
226
|
var focusDecorations = [];
|
|
227
|
+
var isCommentsOnMediaMediaInlineBugFixEnabled = featureFlagsPluginState === null || featureFlagsPluginState === void 0 ? void 0 : featureFlagsPluginState.commentsOnMediaMediaInlineBugFix;
|
|
226
228
|
state.doc.descendants(function (node, pos) {
|
|
227
229
|
var _provider$supportedBl;
|
|
230
|
+
// Inline comment on mediaInline is not supported as part of comments on media project
|
|
231
|
+
// Thus, we skip the decoration for mediaInline node
|
|
232
|
+
if (isCommentsOnMediaMediaInlineBugFixEnabled && node.type.name === 'mediaInline') {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
228
235
|
var isSupportedBlockNode = node.isBlock && ((_provider$supportedBl = provider.supportedBlockNodes) === null || _provider$supportedBl === void 0 ? void 0 : _provider$supportedBl.includes(node.type.name));
|
|
229
236
|
node.marks.filter(function (mark) {
|
|
230
237
|
return mark.type === state.schema.marks.annotation;
|
|
@@ -22,7 +22,7 @@ var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
|
|
|
22
22
|
};
|
|
23
23
|
var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
|
|
24
24
|
return function (tr, pluginState) {
|
|
25
|
-
var _pluginState$featureF;
|
|
25
|
+
var _pluginState$featureF, _pluginState$featureF2;
|
|
26
26
|
if (pluginState.skipSelectionHandling) {
|
|
27
27
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
28
28
|
skipSelectionHandling: false
|
|
@@ -38,7 +38,7 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
|
|
|
38
38
|
isInlineCommentViewClosed: false
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
var selectedAnnotations = (0, _utils2.findAnnotationsInSelection)(tr.selection, tr.doc);
|
|
41
|
+
var selectedAnnotations = (0, _utils2.findAnnotationsInSelection)(tr.selection, tr.doc, (_pluginState$featureF2 = pluginState.featureFlagsPluginState) === null || _pluginState$featureF2 === void 0 ? void 0 : _pluginState$featureF2.commentsOnMediaMediaInlineBugFix);
|
|
42
42
|
if (selectedAnnotations.length === 0) {
|
|
43
43
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
44
44
|
selectedAnnotations: selectedAnnotations,
|
package/dist/cjs/utils.js
CHANGED
|
@@ -167,7 +167,7 @@ var isCurrentBlockNodeSelected = exports.isCurrentBlockNodeSelected = function i
|
|
|
167
167
|
}
|
|
168
168
|
return false;
|
|
169
169
|
};
|
|
170
|
-
var findAnnotationsInSelection = exports.findAnnotationsInSelection = function findAnnotationsInSelection(selection, doc) {
|
|
170
|
+
var findAnnotationsInSelection = exports.findAnnotationsInSelection = function findAnnotationsInSelection(selection, doc, isCommentsOnMediaMediaInlineBugFixEnabled) {
|
|
171
171
|
var empty = selection.empty,
|
|
172
172
|
$anchor = selection.$anchor,
|
|
173
173
|
anchor = selection.anchor;
|
|
@@ -176,11 +176,19 @@ var findAnnotationsInSelection = exports.findAnnotationsInSelection = function f
|
|
|
176
176
|
return [];
|
|
177
177
|
}
|
|
178
178
|
var node = doc.nodeAt(anchor);
|
|
179
|
-
|
|
179
|
+
var nodeBefore = $anchor.nodeBefore;
|
|
180
|
+
if (!node && !nodeBefore) {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Inline comment on mediaInline is not supported as part of comments on media project
|
|
185
|
+
// Hence, we ignore annotations associated with the node when the cursor is right after/before the node
|
|
186
|
+
if (isCommentsOnMediaMediaInlineBugFixEnabled && [nodeBefore, node].some(function (node) {
|
|
187
|
+
return (node === null || node === void 0 ? void 0 : node.type.name) === 'mediaInline';
|
|
188
|
+
})) {
|
|
180
189
|
return [];
|
|
181
190
|
}
|
|
182
191
|
var annotationMark = doc.type.schema.marks.annotation;
|
|
183
|
-
var nodeBefore = $anchor.nodeBefore;
|
|
184
192
|
var anchorAnnotationMarks = (node === null || node === void 0 ? void 0 : node.marks) || [];
|
|
185
193
|
var marks = [];
|
|
186
194
|
if (annotationMark.isInSet(anchorAnnotationMarks)) {
|
|
@@ -159,12 +159,19 @@ export const inlineCommentPlugin = options => {
|
|
|
159
159
|
annotations,
|
|
160
160
|
selectedAnnotations,
|
|
161
161
|
isVisible,
|
|
162
|
-
isInlineCommentViewClosed
|
|
162
|
+
isInlineCommentViewClosed,
|
|
163
|
+
featureFlagsPluginState
|
|
163
164
|
} = getPluginState(state) || {};
|
|
164
165
|
let decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : DecorationSet.empty;
|
|
165
166
|
const focusDecorations = [];
|
|
167
|
+
const isCommentsOnMediaMediaInlineBugFixEnabled = featureFlagsPluginState === null || featureFlagsPluginState === void 0 ? void 0 : featureFlagsPluginState.commentsOnMediaMediaInlineBugFix;
|
|
166
168
|
state.doc.descendants((node, pos) => {
|
|
167
169
|
var _provider$supportedBl;
|
|
170
|
+
// Inline comment on mediaInline is not supported as part of comments on media project
|
|
171
|
+
// Thus, we skip the decoration for mediaInline node
|
|
172
|
+
if (isCommentsOnMediaMediaInlineBugFixEnabled && node.type.name === 'mediaInline') {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
168
175
|
const isSupportedBlockNode = node.isBlock && ((_provider$supportedBl = provider.supportedBlockNodes) === null || _provider$supportedBl === void 0 ? void 0 : _provider$supportedBl.includes(node.type.name));
|
|
169
176
|
node.marks.filter(mark => mark.type === state.schema.marks.annotation).forEach(mark => {
|
|
170
177
|
if (isVisible) {
|
|
@@ -12,7 +12,7 @@ const handleDocChanged = (tr, prevPluginState) => {
|
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => {
|
|
15
|
-
var _pluginState$featureF;
|
|
15
|
+
var _pluginState$featureF, _pluginState$featureF2;
|
|
16
16
|
if (pluginState.skipSelectionHandling) {
|
|
17
17
|
return {
|
|
18
18
|
...pluginState,
|
|
@@ -33,7 +33,7 @@ const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => {
|
|
|
33
33
|
})
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
const selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
|
|
36
|
+
const selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc, (_pluginState$featureF2 = pluginState.featureFlagsPluginState) === null || _pluginState$featureF2 === void 0 ? void 0 : _pluginState$featureF2.commentsOnMediaMediaInlineBugFix);
|
|
37
37
|
if (selectedAnnotations.length === 0) {
|
|
38
38
|
return {
|
|
39
39
|
...pluginState,
|
package/dist/es2019/utils.js
CHANGED
|
@@ -128,7 +128,7 @@ export const isCurrentBlockNodeSelected = (state, node) => {
|
|
|
128
128
|
}
|
|
129
129
|
return false;
|
|
130
130
|
};
|
|
131
|
-
export const findAnnotationsInSelection = (selection, doc) => {
|
|
131
|
+
export const findAnnotationsInSelection = (selection, doc, isCommentsOnMediaMediaInlineBugFixEnabled) => {
|
|
132
132
|
const {
|
|
133
133
|
empty,
|
|
134
134
|
$anchor,
|
|
@@ -139,11 +139,17 @@ export const findAnnotationsInSelection = (selection, doc) => {
|
|
|
139
139
|
return [];
|
|
140
140
|
}
|
|
141
141
|
const node = doc.nodeAt(anchor);
|
|
142
|
-
|
|
142
|
+
const nodeBefore = $anchor.nodeBefore;
|
|
143
|
+
if (!node && !nodeBefore) {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Inline comment on mediaInline is not supported as part of comments on media project
|
|
148
|
+
// Hence, we ignore annotations associated with the node when the cursor is right after/before the node
|
|
149
|
+
if (isCommentsOnMediaMediaInlineBugFixEnabled && [nodeBefore, node].some(node => (node === null || node === void 0 ? void 0 : node.type.name) === 'mediaInline')) {
|
|
143
150
|
return [];
|
|
144
151
|
}
|
|
145
152
|
const annotationMark = doc.type.schema.marks.annotation;
|
|
146
|
-
const nodeBefore = $anchor.nodeBefore;
|
|
147
153
|
const anchorAnnotationMarks = (node === null || node === void 0 ? void 0 : node.marks) || [];
|
|
148
154
|
let marks = [];
|
|
149
155
|
if (annotationMark.isInSet(anchorAnnotationMarks)) {
|
|
@@ -213,11 +213,18 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
213
213
|
annotations = _ref5.annotations,
|
|
214
214
|
selectedAnnotations = _ref5.selectedAnnotations,
|
|
215
215
|
isVisible = _ref5.isVisible,
|
|
216
|
-
isInlineCommentViewClosed = _ref5.isInlineCommentViewClosed
|
|
216
|
+
isInlineCommentViewClosed = _ref5.isInlineCommentViewClosed,
|
|
217
|
+
featureFlagsPluginState = _ref5.featureFlagsPluginState;
|
|
217
218
|
var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : DecorationSet.empty;
|
|
218
219
|
var focusDecorations = [];
|
|
220
|
+
var isCommentsOnMediaMediaInlineBugFixEnabled = featureFlagsPluginState === null || featureFlagsPluginState === void 0 ? void 0 : featureFlagsPluginState.commentsOnMediaMediaInlineBugFix;
|
|
219
221
|
state.doc.descendants(function (node, pos) {
|
|
220
222
|
var _provider$supportedBl;
|
|
223
|
+
// Inline comment on mediaInline is not supported as part of comments on media project
|
|
224
|
+
// Thus, we skip the decoration for mediaInline node
|
|
225
|
+
if (isCommentsOnMediaMediaInlineBugFixEnabled && node.type.name === 'mediaInline') {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
221
228
|
var isSupportedBlockNode = node.isBlock && ((_provider$supportedBl = provider.supportedBlockNodes) === null || _provider$supportedBl === void 0 ? void 0 : _provider$supportedBl.includes(node.type.name));
|
|
222
229
|
node.marks.filter(function (mark) {
|
|
223
230
|
return mark.type === state.schema.marks.annotation;
|
|
@@ -15,7 +15,7 @@ var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
|
|
|
15
15
|
};
|
|
16
16
|
var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
|
|
17
17
|
return function (tr, pluginState) {
|
|
18
|
-
var _pluginState$featureF;
|
|
18
|
+
var _pluginState$featureF, _pluginState$featureF2;
|
|
19
19
|
if (pluginState.skipSelectionHandling) {
|
|
20
20
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
21
21
|
skipSelectionHandling: false
|
|
@@ -31,7 +31,7 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
|
|
|
31
31
|
isInlineCommentViewClosed: false
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
var selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
|
|
34
|
+
var selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc, (_pluginState$featureF2 = pluginState.featureFlagsPluginState) === null || _pluginState$featureF2 === void 0 ? void 0 : _pluginState$featureF2.commentsOnMediaMediaInlineBugFix);
|
|
35
35
|
if (selectedAnnotations.length === 0) {
|
|
36
36
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
37
37
|
selectedAnnotations: selectedAnnotations,
|
package/dist/esm/utils.js
CHANGED
|
@@ -140,7 +140,7 @@ export var isCurrentBlockNodeSelected = function isCurrentBlockNodeSelected(stat
|
|
|
140
140
|
}
|
|
141
141
|
return false;
|
|
142
142
|
};
|
|
143
|
-
export var findAnnotationsInSelection = function findAnnotationsInSelection(selection, doc) {
|
|
143
|
+
export var findAnnotationsInSelection = function findAnnotationsInSelection(selection, doc, isCommentsOnMediaMediaInlineBugFixEnabled) {
|
|
144
144
|
var empty = selection.empty,
|
|
145
145
|
$anchor = selection.$anchor,
|
|
146
146
|
anchor = selection.anchor;
|
|
@@ -149,11 +149,19 @@ export var findAnnotationsInSelection = function findAnnotationsInSelection(sele
|
|
|
149
149
|
return [];
|
|
150
150
|
}
|
|
151
151
|
var node = doc.nodeAt(anchor);
|
|
152
|
-
|
|
152
|
+
var nodeBefore = $anchor.nodeBefore;
|
|
153
|
+
if (!node && !nodeBefore) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Inline comment on mediaInline is not supported as part of comments on media project
|
|
158
|
+
// Hence, we ignore annotations associated with the node when the cursor is right after/before the node
|
|
159
|
+
if (isCommentsOnMediaMediaInlineBugFixEnabled && [nodeBefore, node].some(function (node) {
|
|
160
|
+
return (node === null || node === void 0 ? void 0 : node.type.name) === 'mediaInline';
|
|
161
|
+
})) {
|
|
153
162
|
return [];
|
|
154
163
|
}
|
|
155
164
|
var annotationMark = doc.type.schema.marks.annotation;
|
|
156
|
-
var nodeBefore = $anchor.nodeBefore;
|
|
157
165
|
var anchorAnnotationMarks = (node === null || node === void 0 ? void 0 : node.marks) || [];
|
|
158
166
|
var marks = [];
|
|
159
167
|
if (annotationMark.isInSet(anchorAnnotationMarks)) {
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare const decorationKey: {
|
|
|
21
21
|
export declare const addDraftDecoration: (start: number, end: number, targetType?: TargetType) => Decoration;
|
|
22
22
|
export declare const getAnnotationViewKey: (annotations: AnnotationInfo[]) => string;
|
|
23
23
|
export declare const isCurrentBlockNodeSelected: (state: EditorState, node: Node) => boolean;
|
|
24
|
-
export declare const findAnnotationsInSelection: (selection: Selection, doc: Node) => AnnotationInfo[];
|
|
24
|
+
export declare const findAnnotationsInSelection: (selection: Selection, doc: Node, isCommentsOnMediaMediaInlineBugFixEnabled?: boolean) => AnnotationInfo[];
|
|
25
25
|
export declare const resolveDraftBookmark: (editorState: EditorState, bookmark?: SelectionBookmark, supportedBlockNodes?: string[]) => DraftBookmark;
|
|
26
26
|
/**
|
|
27
27
|
* get selection from position to apply new comment for
|
|
@@ -21,7 +21,7 @@ export declare const decorationKey: {
|
|
|
21
21
|
export declare const addDraftDecoration: (start: number, end: number, targetType?: TargetType) => Decoration;
|
|
22
22
|
export declare const getAnnotationViewKey: (annotations: AnnotationInfo[]) => string;
|
|
23
23
|
export declare const isCurrentBlockNodeSelected: (state: EditorState, node: Node) => boolean;
|
|
24
|
-
export declare const findAnnotationsInSelection: (selection: Selection, doc: Node) => AnnotationInfo[];
|
|
24
|
+
export declare const findAnnotationsInSelection: (selection: Selection, doc: Node, isCommentsOnMediaMediaInlineBugFixEnabled?: boolean) => AnnotationInfo[];
|
|
25
25
|
export declare const resolveDraftBookmark: (editorState: EditorState, bookmark?: SelectionBookmark, supportedBlockNodes?: string[]) => DraftBookmark;
|
|
26
26
|
/**
|
|
27
27
|
* get selection from position to apply new comment for
|