@atlaskit/editor-plugin-annotation 2.1.6 → 2.1.8
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 +18 -0
- package/dist/cjs/annotationPlugin.js +1 -0
- package/dist/cjs/editor-commands/transform.js +14 -2
- package/dist/cjs/pm-plugins/utils.js +41 -5
- package/dist/es2019/annotationPlugin.js +2 -1
- package/dist/es2019/editor-commands/transform.js +12 -2
- package/dist/es2019/pm-plugins/utils.js +31 -4
- package/dist/esm/annotationPlugin.js +2 -1
- package/dist/esm/editor-commands/transform.js +14 -2
- package/dist/esm/pm-plugins/utils.js +39 -4
- package/dist/types/annotationPluginType.d.ts +1 -0
- package/dist/types/editor-commands/transform.d.ts +1 -0
- package/dist/types/pm-plugins/utils.d.ts +1 -0
- package/dist/types-ts4.5/annotationPluginType.d.ts +1 -0
- package/dist/types-ts4.5/editor-commands/transform.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +1 -0
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 2.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#129644](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/129644)
|
|
8
|
+
[`f3daef1b37b2f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f3daef1b37b2f) -
|
|
9
|
+
Fix setting the annotation selection after adding a comment if it is no longer in the annotation.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 2.1.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#128761](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/128761)
|
|
17
|
+
[`917104463449c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/917104463449c) -
|
|
18
|
+
Ensure the selected annotation state accounts for selections that are in between two annotations.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 2.1.6
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -32,6 +32,7 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
32
32
|
}];
|
|
33
33
|
},
|
|
34
34
|
actions: {
|
|
35
|
+
hasAnyUnResolvedAnnotationInPage: _utils.hasAnyUnResolvedAnnotationInPage,
|
|
35
36
|
stripNonExistingAnnotations: _utils.stripNonExistingAnnotations,
|
|
36
37
|
setInlineCommentDraftState: (0, _editorCommands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
|
|
37
38
|
showCommentForBlockNode: (0, _editorCommands.showInlineCommentForBlockNode)(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
|
|
@@ -9,8 +9,12 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
9
9
|
var _mark = require("@atlaskit/editor-common/mark");
|
|
10
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
12
13
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _utils2 = require("../pm-plugins/utils");
|
|
15
|
+
var isAnnotationStep = function isAnnotationStep(step) {
|
|
16
|
+
return step instanceof _transform.AddMarkStep && step.mark.type.name === 'annotation';
|
|
17
|
+
};
|
|
14
18
|
var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
|
|
15
19
|
return function (transaction, state) {
|
|
16
20
|
var inlineCommentState = (0, _utils2.getPluginState)(state);
|
|
@@ -33,8 +37,16 @@ var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
|
|
|
33
37
|
} else {
|
|
34
38
|
// Apply the mark only to text node in the range.
|
|
35
39
|
var _tr = (0, _mark.applyMarkOnRange)(from, to, false, annotationMark, transaction);
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
|
|
41
|
+
// The mark may not be applied to the current "head" of the bookmark so determine what was applied
|
|
42
|
+
// above and use that instead
|
|
43
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_missing_selected_annotations')) {
|
|
44
|
+
var annotationMarkStep = _tr.steps.reverse().find(isAnnotationStep);
|
|
45
|
+
var headBasedOnMark = from === head ? annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.from : annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.to;
|
|
46
|
+
_tr.setSelection(_state.TextSelection.create(_tr.doc, headBasedOnMark !== null && headBasedOnMark !== void 0 ? headBasedOnMark : head));
|
|
47
|
+
} else {
|
|
48
|
+
_tr.setSelection(_state.TextSelection.create(_tr.doc, head));
|
|
49
|
+
}
|
|
38
50
|
}
|
|
39
51
|
return tr;
|
|
40
52
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -7,13 +8,14 @@ exports.addDraftDecoration = void 0;
|
|
|
7
8
|
exports.annotationExists = annotationExists;
|
|
8
9
|
exports.getPluginState = exports.getDraftCommandAnalyticsPayload = exports.getAnnotationViewKey = exports.getAllAnnotations = exports.findAnnotationsInSelection = exports.decorationKey = void 0;
|
|
9
10
|
exports.getSelectionPositions = getSelectionPositions;
|
|
10
|
-
exports.hasInvalidNodes = void 0;
|
|
11
|
+
exports.hasInvalidNodes = exports.hasAnyUnResolvedAnnotationInPage = void 0;
|
|
11
12
|
exports.hasInvalidWhitespaceNode = hasInvalidWhitespaceNode;
|
|
12
13
|
exports.isCurrentBlockNodeSelected = exports.isBlockNodeAnnotationsSelected = exports.inlineCommentPluginKey = void 0;
|
|
13
14
|
exports.isSelectedAnnotationsChanged = isSelectedAnnotationsChanged;
|
|
14
15
|
exports.resolveDraftBookmark = exports.isSupportedBlockNode = exports.isSelectionValid = void 0;
|
|
15
16
|
exports.stripNonExistingAnnotations = stripNonExistingAnnotations;
|
|
16
17
|
exports.surroundingMarks = void 0;
|
|
18
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
19
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
18
20
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
19
21
|
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
@@ -187,10 +189,25 @@ var findAnnotationsInSelection = exports.findAnnotationsInSelection = function f
|
|
|
187
189
|
var annotationMark = doc.type.schema.marks.annotation;
|
|
188
190
|
var anchorAnnotationMarks = (node === null || node === void 0 ? void 0 : node.marks) || [];
|
|
189
191
|
var marks = [];
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_missing_selected_annotations')) {
|
|
193
|
+
if (annotationMark.isInSet(anchorAnnotationMarks)) {
|
|
194
|
+
marks = anchorAnnotationMarks;
|
|
195
|
+
}
|
|
196
|
+
if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
|
|
197
|
+
var _marks;
|
|
198
|
+
var existingMarkIds = marks.map(function (m) {
|
|
199
|
+
return m.attrs.id;
|
|
200
|
+
});
|
|
201
|
+
marks = (_marks = marks).concat.apply(_marks, (0, _toConsumableArray2.default)(nodeBefore.marks.filter(function (m) {
|
|
202
|
+
return !existingMarkIds.includes(m.attrs.id);
|
|
203
|
+
})));
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
if (annotationMark.isInSet(anchorAnnotationMarks)) {
|
|
207
|
+
marks = anchorAnnotationMarks;
|
|
208
|
+
} else if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
|
|
209
|
+
marks = nodeBefore.marks;
|
|
210
|
+
}
|
|
194
211
|
}
|
|
195
212
|
var annotations = marks.filter(function (mark) {
|
|
196
213
|
return mark.type.name === 'annotation';
|
|
@@ -490,4 +507,23 @@ var isBlockNodeAnnotationsSelected = exports.isBlockNodeAnnotationsSelected = fu
|
|
|
490
507
|
});
|
|
491
508
|
}
|
|
492
509
|
return false;
|
|
510
|
+
};
|
|
511
|
+
var hasAnyUnResolvedAnnotationInPage = exports.hasAnyUnResolvedAnnotationInPage = function hasAnyUnResolvedAnnotationInPage(state) {
|
|
512
|
+
var _getPluginState;
|
|
513
|
+
var annotations = (_getPluginState = getPluginState(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.annotations;
|
|
514
|
+
if (annotations) {
|
|
515
|
+
/**
|
|
516
|
+
* annotations type is { [key: string]: boolean };
|
|
517
|
+
* Here, key represents mark.attr.id and it is used to find where annotation to be presented in the document.
|
|
518
|
+
* When value is false, it means it is unresolved annotation.
|
|
519
|
+
*
|
|
520
|
+
* But sometimes annotation map has entry with key undefined somehow.
|
|
521
|
+
* And it is not valid mark attribute id, so it won't be presented anywhere in the document.
|
|
522
|
+
*/
|
|
523
|
+
var unresolvedAnnotationKeys = Object.keys(annotations).filter(function (key) {
|
|
524
|
+
return key !== 'undefined' && annotations[key] === false;
|
|
525
|
+
});
|
|
526
|
+
return unresolvedAnnotationKeys.length > 0;
|
|
527
|
+
}
|
|
528
|
+
return false;
|
|
493
529
|
};
|
|
@@ -6,7 +6,7 @@ import { annotationWithToDOMFix } from './nodeviews/annotationMark';
|
|
|
6
6
|
import { inlineCommentPlugin } from './pm-plugins/inline-comment';
|
|
7
7
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
8
8
|
import { buildToolbar } from './pm-plugins/toolbar';
|
|
9
|
-
import { getPluginState, stripNonExistingAnnotations } from './pm-plugins/utils';
|
|
9
|
+
import { getPluginState, hasAnyUnResolvedAnnotationInPage, stripNonExistingAnnotations } from './pm-plugins/utils';
|
|
10
10
|
import { InlineCommentView } from './ui/InlineCommentView';
|
|
11
11
|
export const annotationPlugin = ({
|
|
12
12
|
config: annotationProviders,
|
|
@@ -23,6 +23,7 @@ export const annotationPlugin = ({
|
|
|
23
23
|
}];
|
|
24
24
|
},
|
|
25
25
|
actions: {
|
|
26
|
+
hasAnyUnResolvedAnnotationInPage,
|
|
26
27
|
stripNonExistingAnnotations,
|
|
27
28
|
setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
|
|
28
29
|
showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
|
|
@@ -3,8 +3,10 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
|
|
|
3
3
|
import { applyMarkOnRange } from '@atlaskit/editor-common/mark';
|
|
4
4
|
import { getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { getDraftCommandAnalyticsPayload, getPluginState, resolveDraftBookmark } from '../pm-plugins/utils';
|
|
9
|
+
const isAnnotationStep = step => step instanceof AddMarkStep && step.mark.type.name === 'annotation';
|
|
8
10
|
const addAnnotationMark = (id, supportedBlockNodes) => (transaction, state) => {
|
|
9
11
|
const inlineCommentState = getPluginState(state);
|
|
10
12
|
const {
|
|
@@ -28,8 +30,16 @@ const addAnnotationMark = (id, supportedBlockNodes) => (transaction, state) => {
|
|
|
28
30
|
} else {
|
|
29
31
|
// Apply the mark only to text node in the range.
|
|
30
32
|
const tr = applyMarkOnRange(from, to, false, annotationMark, transaction);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
|
|
34
|
+
// The mark may not be applied to the current "head" of the bookmark so determine what was applied
|
|
35
|
+
// above and use that instead
|
|
36
|
+
if (fg('platform_editor_fix_missing_selected_annotations')) {
|
|
37
|
+
const annotationMarkStep = tr.steps.reverse().find(isAnnotationStep);
|
|
38
|
+
const headBasedOnMark = from === head ? annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.from : annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.to;
|
|
39
|
+
tr.setSelection(TextSelection.create(tr.doc, headBasedOnMark !== null && headBasedOnMark !== void 0 ? headBasedOnMark : head));
|
|
40
|
+
} else {
|
|
41
|
+
tr.setSelection(TextSelection.create(tr.doc, head));
|
|
42
|
+
}
|
|
33
43
|
}
|
|
34
44
|
return tr;
|
|
35
45
|
};
|
|
@@ -159,10 +159,20 @@ export const findAnnotationsInSelection = (selection, doc) => {
|
|
|
159
159
|
const annotationMark = doc.type.schema.marks.annotation;
|
|
160
160
|
const anchorAnnotationMarks = (node === null || node === void 0 ? void 0 : node.marks) || [];
|
|
161
161
|
let marks = [];
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
if (fg('platform_editor_fix_missing_selected_annotations')) {
|
|
163
|
+
if (annotationMark.isInSet(anchorAnnotationMarks)) {
|
|
164
|
+
marks = anchorAnnotationMarks;
|
|
165
|
+
}
|
|
166
|
+
if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
|
|
167
|
+
const existingMarkIds = marks.map(m => m.attrs.id);
|
|
168
|
+
marks = marks.concat(...nodeBefore.marks.filter(m => !existingMarkIds.includes(m.attrs.id)));
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
if (annotationMark.isInSet(anchorAnnotationMarks)) {
|
|
172
|
+
marks = anchorAnnotationMarks;
|
|
173
|
+
} else if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
|
|
174
|
+
marks = nodeBefore.marks;
|
|
175
|
+
}
|
|
166
176
|
}
|
|
167
177
|
const annotations = marks.filter(mark => mark.type.name === 'annotation').map(mark => ({
|
|
168
178
|
id: mark.attrs.id,
|
|
@@ -454,4 +464,21 @@ export const isBlockNodeAnnotationsSelected = (selection, selectedAnnotations =
|
|
|
454
464
|
return !selectedAnnotations.some(annotation => !annotationMarks.find(existingAnnotation => existingAnnotation.id === annotation.id && existingAnnotation.type === annotation.type));
|
|
455
465
|
}
|
|
456
466
|
return false;
|
|
467
|
+
};
|
|
468
|
+
export const hasAnyUnResolvedAnnotationInPage = state => {
|
|
469
|
+
var _getPluginState;
|
|
470
|
+
const annotations = (_getPluginState = getPluginState(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.annotations;
|
|
471
|
+
if (annotations) {
|
|
472
|
+
/**
|
|
473
|
+
* annotations type is { [key: string]: boolean };
|
|
474
|
+
* Here, key represents mark.attr.id and it is used to find where annotation to be presented in the document.
|
|
475
|
+
* When value is false, it means it is unresolved annotation.
|
|
476
|
+
*
|
|
477
|
+
* But sometimes annotation map has entry with key undefined somehow.
|
|
478
|
+
* And it is not valid mark attribute id, so it won't be presented anywhere in the document.
|
|
479
|
+
*/
|
|
480
|
+
const unresolvedAnnotationKeys = Object.keys(annotations).filter(key => key !== 'undefined' && annotations[key] === false);
|
|
481
|
+
return unresolvedAnnotationKeys.length > 0;
|
|
482
|
+
}
|
|
483
|
+
return false;
|
|
457
484
|
};
|
|
@@ -9,7 +9,7 @@ import { annotationWithToDOMFix } from './nodeviews/annotationMark';
|
|
|
9
9
|
import { inlineCommentPlugin } from './pm-plugins/inline-comment';
|
|
10
10
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
11
11
|
import { buildToolbar } from './pm-plugins/toolbar';
|
|
12
|
-
import { getPluginState, stripNonExistingAnnotations } from './pm-plugins/utils';
|
|
12
|
+
import { getPluginState, hasAnyUnResolvedAnnotationInPage, stripNonExistingAnnotations } from './pm-plugins/utils';
|
|
13
13
|
import { InlineCommentView } from './ui/InlineCommentView';
|
|
14
14
|
export var annotationPlugin = function annotationPlugin(_ref) {
|
|
15
15
|
var _api$featureFlags, _api$analytics;
|
|
@@ -25,6 +25,7 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
25
25
|
}];
|
|
26
26
|
},
|
|
27
27
|
actions: {
|
|
28
|
+
hasAnyUnResolvedAnnotationInPage: hasAnyUnResolvedAnnotationInPage,
|
|
28
29
|
stripNonExistingAnnotations: stripNonExistingAnnotations,
|
|
29
30
|
setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
|
|
30
31
|
showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
|
|
@@ -3,8 +3,12 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
|
|
|
3
3
|
import { applyMarkOnRange } from '@atlaskit/editor-common/mark';
|
|
4
4
|
import { getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { getDraftCommandAnalyticsPayload, getPluginState, resolveDraftBookmark } from '../pm-plugins/utils';
|
|
9
|
+
var isAnnotationStep = function isAnnotationStep(step) {
|
|
10
|
+
return step instanceof AddMarkStep && step.mark.type.name === 'annotation';
|
|
11
|
+
};
|
|
8
12
|
var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
|
|
9
13
|
return function (transaction, state) {
|
|
10
14
|
var inlineCommentState = getPluginState(state);
|
|
@@ -27,8 +31,16 @@ var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
|
|
|
27
31
|
} else {
|
|
28
32
|
// Apply the mark only to text node in the range.
|
|
29
33
|
var _tr = applyMarkOnRange(from, to, false, annotationMark, transaction);
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
|
|
35
|
+
// The mark may not be applied to the current "head" of the bookmark so determine what was applied
|
|
36
|
+
// above and use that instead
|
|
37
|
+
if (fg('platform_editor_fix_missing_selected_annotations')) {
|
|
38
|
+
var annotationMarkStep = _tr.steps.reverse().find(isAnnotationStep);
|
|
39
|
+
var headBasedOnMark = from === head ? annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.from : annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.to;
|
|
40
|
+
_tr.setSelection(TextSelection.create(_tr.doc, headBasedOnMark !== null && headBasedOnMark !== void 0 ? headBasedOnMark : head));
|
|
41
|
+
} else {
|
|
42
|
+
_tr.setSelection(TextSelection.create(_tr.doc, head));
|
|
43
|
+
}
|
|
32
44
|
}
|
|
33
45
|
return tr;
|
|
34
46
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
2
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
@@ -171,10 +172,25 @@ export var findAnnotationsInSelection = function findAnnotationsInSelection(sele
|
|
|
171
172
|
var annotationMark = doc.type.schema.marks.annotation;
|
|
172
173
|
var anchorAnnotationMarks = (node === null || node === void 0 ? void 0 : node.marks) || [];
|
|
173
174
|
var marks = [];
|
|
174
|
-
if (
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
if (fg('platform_editor_fix_missing_selected_annotations')) {
|
|
176
|
+
if (annotationMark.isInSet(anchorAnnotationMarks)) {
|
|
177
|
+
marks = anchorAnnotationMarks;
|
|
178
|
+
}
|
|
179
|
+
if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
|
|
180
|
+
var _marks;
|
|
181
|
+
var existingMarkIds = marks.map(function (m) {
|
|
182
|
+
return m.attrs.id;
|
|
183
|
+
});
|
|
184
|
+
marks = (_marks = marks).concat.apply(_marks, _toConsumableArray(nodeBefore.marks.filter(function (m) {
|
|
185
|
+
return !existingMarkIds.includes(m.attrs.id);
|
|
186
|
+
})));
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
if (annotationMark.isInSet(anchorAnnotationMarks)) {
|
|
190
|
+
marks = anchorAnnotationMarks;
|
|
191
|
+
} else if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
|
|
192
|
+
marks = nodeBefore.marks;
|
|
193
|
+
}
|
|
178
194
|
}
|
|
179
195
|
var annotations = marks.filter(function (mark) {
|
|
180
196
|
return mark.type.name === 'annotation';
|
|
@@ -474,4 +490,23 @@ export var isBlockNodeAnnotationsSelected = function isBlockNodeAnnotationsSelec
|
|
|
474
490
|
});
|
|
475
491
|
}
|
|
476
492
|
return false;
|
|
493
|
+
};
|
|
494
|
+
export var hasAnyUnResolvedAnnotationInPage = function hasAnyUnResolvedAnnotationInPage(state) {
|
|
495
|
+
var _getPluginState;
|
|
496
|
+
var annotations = (_getPluginState = getPluginState(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.annotations;
|
|
497
|
+
if (annotations) {
|
|
498
|
+
/**
|
|
499
|
+
* annotations type is { [key: string]: boolean };
|
|
500
|
+
* Here, key represents mark.attr.id and it is used to find where annotation to be presented in the document.
|
|
501
|
+
* When value is false, it means it is unresolved annotation.
|
|
502
|
+
*
|
|
503
|
+
* But sometimes annotation map has entry with key undefined somehow.
|
|
504
|
+
* And it is not valid mark attribute id, so it won't be presented anywhere in the document.
|
|
505
|
+
*/
|
|
506
|
+
var unresolvedAnnotationKeys = Object.keys(annotations).filter(function (key) {
|
|
507
|
+
return key !== 'undefined' && annotations[key] === false;
|
|
508
|
+
});
|
|
509
|
+
return unresolvedAnnotationKeys.length > 0;
|
|
510
|
+
}
|
|
511
|
+
return false;
|
|
477
512
|
};
|
|
@@ -33,6 +33,7 @@ export type AnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
|
33
33
|
* otherwise, it will return false.
|
|
34
34
|
*/
|
|
35
35
|
showCommentForBlockNode: ReturnType<typeof showInlineCommentForBlockNode>;
|
|
36
|
+
hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
|
|
36
37
|
};
|
|
37
38
|
}>;
|
|
38
39
|
export {};
|
|
@@ -11,6 +11,7 @@ declare const _default: {
|
|
|
11
11
|
stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
|
|
12
12
|
setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
13
13
|
showCommentForBlockNode: (node: import("prosemirror-model").Node | null, viewMethod?: import("@atlaskit/editor-common/analytics").VIEW_METHOD | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
14
|
+
hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
|
|
14
15
|
};
|
|
15
16
|
}> | undefined) => (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
16
17
|
handleDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
@@ -51,3 +51,4 @@ export declare function isSelectedAnnotationsChanged(oldSelectedAnnotations: Ann
|
|
|
51
51
|
* Checks if the selectedAnnotations are the same as the annotations on the selected block node
|
|
52
52
|
*/
|
|
53
53
|
export declare const isBlockNodeAnnotationsSelected: (selection: Selection, selectedAnnotations?: AnnotationInfo[]) => boolean;
|
|
54
|
+
export declare const hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
|
|
@@ -33,6 +33,7 @@ export type AnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
|
33
33
|
* otherwise, it will return false.
|
|
34
34
|
*/
|
|
35
35
|
showCommentForBlockNode: ReturnType<typeof showInlineCommentForBlockNode>;
|
|
36
|
+
hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
|
|
36
37
|
};
|
|
37
38
|
}>;
|
|
38
39
|
export {};
|
|
@@ -11,6 +11,7 @@ declare const _default: {
|
|
|
11
11
|
stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
|
|
12
12
|
setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
13
13
|
showCommentForBlockNode: (node: import("prosemirror-model").Node | null, viewMethod?: import("@atlaskit/editor-common/analytics").VIEW_METHOD | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
14
|
+
hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
|
|
14
15
|
};
|
|
15
16
|
}> | undefined) => (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
16
17
|
handleDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
@@ -51,3 +51,4 @@ export declare function isSelectedAnnotationsChanged(oldSelectedAnnotations: Ann
|
|
|
51
51
|
* Checks if the selectedAnnotations are the same as the annotations on the selected block node
|
|
52
52
|
*/
|
|
53
53
|
export declare const isBlockNodeAnnotationsSelected: (selection: Selection, selectedAnnotations?: AnnotationInfo[]) => boolean;
|
|
54
|
+
export declare const hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.8",
|
|
4
4
|
"description": "Annotation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
35
|
-
"@atlaskit/editor-common": "^102.
|
|
35
|
+
"@atlaskit/editor-common": "^102.11.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
37
37
|
"@atlaskit/editor-plugin-connectivity": "^2.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-editor-viewmode-effects": "^2.0.0",
|
|
@@ -99,6 +99,9 @@
|
|
|
99
99
|
"platform_inline_node_as_valid_annotation_selection": {
|
|
100
100
|
"type": "boolean"
|
|
101
101
|
},
|
|
102
|
+
"platform_editor_fix_missing_selected_annotations": {
|
|
103
|
+
"type": "boolean"
|
|
104
|
+
},
|
|
102
105
|
"use_comments_data_annotation_updater": {
|
|
103
106
|
"type": "boolean"
|
|
104
107
|
}
|