@atlaskit/renderer 148.0.4 → 149.0.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 +39 -0
- package/dist/cjs/actions/index.js +35 -3
- package/dist/cjs/entry-points/expand-body.js +12 -0
- package/dist/cjs/react/index.js +8 -0
- package/dist/cjs/react/marks/annotation.js +3 -1
- package/dist/cjs/react/nodes/extension-comments.compiled.css +4 -0
- package/dist/cjs/react/nodes/extension-comments.js +144 -0
- package/dist/cjs/react/nodes/extension.js +86 -11
- package/dist/cjs/steps/index.js +23 -0
- package/dist/cjs/ui/Expand.js +10 -0
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/cjs/ui/annotations/contexts/AnnotationRangeContext.js +29 -11
- package/dist/cjs/ui/annotations/element/extension.compiled.css +6 -0
- package/dist/cjs/ui/annotations/element/extension.js +34 -0
- package/dist/cjs/ui/annotations/element/index.js +4 -2
- package/dist/cjs/ui/annotations/element/mark.js +11 -1
- package/dist/cjs/ui/annotations/index.js +2 -1
- package/dist/es2019/actions/index.js +33 -3
- package/dist/es2019/entry-points/expand-body.js +3 -0
- package/dist/es2019/react/index.js +8 -0
- package/dist/es2019/react/marks/annotation.js +3 -1
- package/dist/es2019/react/nodes/extension-comments.compiled.css +4 -0
- package/dist/es2019/react/nodes/extension-comments.js +115 -0
- package/dist/es2019/react/nodes/extension.js +83 -7
- package/dist/es2019/steps/index.js +25 -0
- package/dist/es2019/ui/Expand.js +10 -0
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/es2019/ui/annotations/contexts/AnnotationRangeContext.js +28 -12
- package/dist/es2019/ui/annotations/element/extension.compiled.css +6 -0
- package/dist/es2019/ui/annotations/element/extension.js +26 -0
- package/dist/es2019/ui/annotations/element/index.js +4 -2
- package/dist/es2019/ui/annotations/element/mark.js +11 -1
- package/dist/es2019/ui/annotations/index.js +2 -1
- package/dist/esm/actions/index.js +35 -3
- package/dist/esm/entry-points/expand-body.js +3 -0
- package/dist/esm/react/index.js +8 -0
- package/dist/esm/react/marks/annotation.js +3 -1
- package/dist/esm/react/nodes/extension-comments.compiled.css +4 -0
- package/dist/esm/react/nodes/extension-comments.js +135 -0
- package/dist/esm/react/nodes/extension.js +86 -7
- package/dist/esm/steps/index.js +23 -0
- package/dist/esm/ui/Expand.js +10 -0
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/esm/ui/annotations/contexts/AnnotationRangeContext.js +30 -12
- package/dist/esm/ui/annotations/element/extension.compiled.css +6 -0
- package/dist/esm/ui/annotations/element/extension.js +27 -0
- package/dist/esm/ui/annotations/element/index.js +4 -2
- package/dist/esm/ui/annotations/element/mark.js +11 -1
- package/dist/esm/ui/annotations/index.js +2 -1
- package/dist/types/actions/index.d.ts +13 -0
- package/dist/types/entry-points/expand-body.d.ts +2 -0
- package/dist/types/react/marks/annotation.d.ts +1 -1
- package/dist/types/react/nodes/extension-comments.d.ts +17 -0
- package/dist/types/react/nodes/extension.d.ts +12 -0
- package/dist/types/react/types.d.ts +1 -0
- package/dist/types/ui/annotations/contexts/AnnotationRangeContext.d.ts +4 -2
- package/dist/types/ui/annotations/element/extension.d.ts +17 -0
- package/dist/types/ui/annotations/element/index.d.ts +2 -1
- package/dist/types/ui/annotations/element/mark.d.ts +3 -107
- package/dist/types/ui/utils/expand-body.d.ts +5 -3
- package/expand-body/package.json +10 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 149.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6887d068f2246`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6887d068f2246) -
|
|
8
|
+
[ux] Add hover and keyboard-focus comment targeting and unresolved comment badges for eligible
|
|
9
|
+
extensions in the renderer behind cc_maui_annotations_on_extensions. Add the optional
|
|
10
|
+
isBlockNodeSupported provider predicate in editor-common. Convert renderer positions to node
|
|
11
|
+
positions so chart comments create node marks, and preserve the hover range when focus moves
|
|
12
|
+
between controls within a chart. Memoize extension comment eligibility by node and provider
|
|
13
|
+
predicate to avoid repeating manifest lookups on unrelated renders. Keep the hover-target callback
|
|
14
|
+
stable as draft ranges change. Explicitly gate extension range-to-position conversion so disabling
|
|
15
|
+
cc_maui_annotations_on_extensions preserves the previous text and media targeting behavior.
|
|
16
|
+
|
|
17
|
+
Keep chart draft anchors and local comment creation on the selected extension, and render saved
|
|
18
|
+
annotation anchors beside the chart contents so adding or removing comments does not remount the
|
|
19
|
+
iframe. These fixes remain behind cc_maui_annotations_on_extensions.
|
|
20
|
+
|
|
21
|
+
Use node-mark removal for eligible extension comments so deleting a chart comment removes its
|
|
22
|
+
annotation from the returned document and sends the correct removal step for persistence, behind
|
|
23
|
+
cc_maui_annotations_on_extensions.
|
|
24
|
+
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
|
|
27
|
+
## 148.1.0
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- [`f115a893c63dd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f115a893c63dd) -
|
|
32
|
+
Exports `ExpandBodyProvider` (`@atlaskit/renderer/expand-body`), so a product can provide the
|
|
33
|
+
outermost expand body itself. Expands under it share one `revealedByFind` set, so they come back
|
|
34
|
+
as browser find left them when the product remounts them, such as when it replaces a lightly
|
|
35
|
+
rendered subtree with its full render. Under `cc_light_mode_table_virtualization`, the set also
|
|
36
|
+
records expands the reader opens and closes, so they come back as the reader left them too.
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies
|
|
41
|
+
|
|
3
42
|
## 148.0.4
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
|
@@ -94,9 +94,10 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
94
94
|
var to;
|
|
95
95
|
var nodePos;
|
|
96
96
|
var step;
|
|
97
|
+
var schema = this.schema;
|
|
97
98
|
this.doc.descendants(function (node, pos) {
|
|
98
99
|
var found = mark.isInSet(node.marks);
|
|
99
|
-
if (found && node
|
|
100
|
+
if (found && (0, _matchesUtils.isBlockAnnotationTarget)(node, schema)) {
|
|
100
101
|
nodePos = pos;
|
|
101
102
|
}
|
|
102
103
|
if (found && !from) {
|
|
@@ -191,13 +192,12 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
191
192
|
key: "isRangeAnnotatable",
|
|
192
193
|
value: function isRangeAnnotatable(range) {
|
|
193
194
|
try {
|
|
194
|
-
var _startContainer$paren, _endContainer$parentE;
|
|
195
195
|
if (!range) {
|
|
196
196
|
return false;
|
|
197
197
|
}
|
|
198
198
|
var startContainer = range.startContainer,
|
|
199
199
|
endContainer = range.endContainer;
|
|
200
|
-
if ((
|
|
200
|
+
if (this.isInsideNestedExtensionRenderer(startContainer) || this.isInsideNestedExtensionRenderer(endContainer)) {
|
|
201
201
|
return false;
|
|
202
202
|
}
|
|
203
203
|
return this.isValidAnnotationRange(range);
|
|
@@ -213,6 +213,38 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
/**
|
|
217
|
+
* A range only threatens a nested renderer's own document (e.g. a bodiedExtension's macro
|
|
218
|
+
* body, which renders its own nested `<Renderer>`) when it sits inside that nested renderer's
|
|
219
|
+
* `.ak-renderer-document`. Landing directly on the extension's own outer wrapper -- with no
|
|
220
|
+
* nested document in between -- must stay annotatable so the whole chart/extension can be
|
|
221
|
+
* targeted (MAUI-1256), rather than being rejected outright the way any range touching
|
|
222
|
+
* `.ak-renderer-extension` previously was.
|
|
223
|
+
*
|
|
224
|
+
* Behind `cc_maui_annotations_on_extensions` -- the same gate MAUI-1255 added for extension
|
|
225
|
+
* node-mark support -- to preserve the previous behaviour (reject anything touching
|
|
226
|
+
* `.ak-renderer-extension`) while the feature is off.
|
|
227
|
+
*/
|
|
228
|
+
}, {
|
|
229
|
+
key: "isInsideNestedExtensionRenderer",
|
|
230
|
+
value: function isInsideNestedExtensionRenderer(container) {
|
|
231
|
+
// Preserve the legacy parent-based rejection while the gate is disabled.
|
|
232
|
+
if (!(0, _fg.fg)('cc_maui_annotations_on_extensions')) {
|
|
233
|
+
var _container$parentElem;
|
|
234
|
+
return !!((_container$parentElem = container.parentElement) !== null && _container$parentElem !== void 0 && _container$parentElem.closest('.ak-renderer-extension'));
|
|
235
|
+
}
|
|
236
|
+
var element = container instanceof Element ? container : container.parentElement;
|
|
237
|
+
if (!element) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
var extensionAncestor = element.closest('.ak-renderer-extension');
|
|
241
|
+
if (!extensionAncestor) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
var nestedDocument = element.closest('.ak-renderer-document');
|
|
245
|
+
return !!nestedDocument && extensionAncestor.contains(nestedDocument);
|
|
246
|
+
}
|
|
247
|
+
|
|
216
248
|
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
217
249
|
/**
|
|
218
250
|
* This is replaced by `isRangeAnnotatable`.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ExpandBodyProvider", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _expandBody.ExpandBodyProvider;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _expandBody = require("../ui/utils/expand-body");
|
package/dist/cjs/react/index.js
CHANGED
|
@@ -104,6 +104,11 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
|
|
|
104
104
|
if (shouldSkipLinkMark(mark) || shouldSkipBorderMark(mark)) {
|
|
105
105
|
return content;
|
|
106
106
|
}
|
|
107
|
+
// Extension annotations are sibling anchors inside the stable extension shell.
|
|
108
|
+
// Wrapping the extension here would remount its iframe whenever marks change.
|
|
109
|
+
if (node.type.name === 'extension' && mark.type.name === 'annotation' && _this.allowAnnotations && (0, _fg.fg)('cc_maui_annotations_on_extensions')) {
|
|
110
|
+
return content;
|
|
111
|
+
}
|
|
107
112
|
return _this.renderMark((0, _marks.toReact)(mark), _this.withMediaMarkProps(node, mark, _this.getMarkProps(mark, [], node)), "".concat(mark.type.name, "-").concat(index), content);
|
|
108
113
|
}, serializedContent);
|
|
109
114
|
return (0, _expandBody.withExpandBodyBlock)(node, currentPath, index, serialized);
|
|
@@ -556,6 +561,9 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
|
|
|
556
561
|
var _this$getExtensionHei;
|
|
557
562
|
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
558
563
|
return _objectSpread(_objectSpread({}, this.getProps(node, path)), {}, {
|
|
564
|
+
allowAnnotations: this.allowAnnotations,
|
|
565
|
+
allowAnnotationsDraftMode: this.surroundTextNodesWithTextWrapper,
|
|
566
|
+
extensionNode: node,
|
|
559
567
|
extensionViewportSizes: this.extensionViewportSizes,
|
|
560
568
|
hideExtensionKeysWhilePending: this.hideExtensionKeysWhilePending,
|
|
561
569
|
nodeHeight: (_this$getExtensionHei = this.getExtensionHeight) === null || _this$getExtensionHei === void 0 ? void 0 : _this$getExtensionHei.call(this, node),
|
|
@@ -24,6 +24,7 @@ var AnnotationComponent = function AnnotationComponent(_ref) {
|
|
|
24
24
|
annotationParentIds = _ref$annotationParent === void 0 ? [] : _ref$annotationParent,
|
|
25
25
|
allowAnnotations = _ref.allowAnnotations,
|
|
26
26
|
useBlockLevel = _ref.useBlockLevel,
|
|
27
|
+
isExtension = _ref.isExtension,
|
|
27
28
|
isMediaInline = _ref.isMediaInline;
|
|
28
29
|
var data = _objectSpread(_objectSpread({}, dataAttributes), (0, _annotation.buildDataAttributes)({
|
|
29
30
|
id: id,
|
|
@@ -43,7 +44,8 @@ var AnnotationComponent = function AnnotationComponent(_ref) {
|
|
|
43
44
|
dataAttributes: data,
|
|
44
45
|
annotationParentIds: annotationParentIds,
|
|
45
46
|
annotationType: annotationType,
|
|
46
|
-
useBlockLevel: useBlockLevel
|
|
47
|
+
useBlockLevel: useBlockLevel,
|
|
48
|
+
isExtension: isExtension
|
|
47
49
|
}, children);
|
|
48
50
|
}
|
|
49
51
|
return (
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* extension-comments.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.ExtensionComments = void 0;
|
|
10
|
+
require("./extension-comments.compiled.css");
|
|
11
|
+
var _runtime = require("@compiled/react/runtime");
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _annotation = require("@atlaskit/adf-schema/annotation");
|
|
15
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
16
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
17
|
+
var _types = require("@atlaskit/editor-common/types");
|
|
18
|
+
var _AnnotationManagerContext = require("../../ui/annotations/contexts/AnnotationManagerContext");
|
|
19
|
+
var _AnnotationRangeContext = require("../../ui/annotations/contexts/AnnotationRangeContext");
|
|
20
|
+
var _useInlineCommentSubscriber = require("../../ui/annotations/hooks/use-inline-comment-subscriber");
|
|
21
|
+
var _useInlineCommentsFilter = require("../../ui/annotations/hooks/use-inline-comments-filter");
|
|
22
|
+
var _annotation2 = _interopRequireDefault(require("../marks/annotation"));
|
|
23
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
24
|
+
var containerStyles = null;
|
|
25
|
+
var annotationParentIds = [];
|
|
26
|
+
var annotationDataAttributes = {
|
|
27
|
+
'data-renderer-mark': true,
|
|
28
|
+
'data-block-mark': true
|
|
29
|
+
};
|
|
30
|
+
var badgeStyles = null;
|
|
31
|
+
var ExtensionCommentsEnabled = function ExtensionCommentsEnabled(_ref) {
|
|
32
|
+
var marks = _ref.marks,
|
|
33
|
+
children = _ref.children,
|
|
34
|
+
enabled = _ref.enabled,
|
|
35
|
+
allowAnnotations = _ref.allowAnnotations,
|
|
36
|
+
allowAnnotationsDraftMode = _ref.allowAnnotationsDraftMode,
|
|
37
|
+
startPos = _ref.startPos;
|
|
38
|
+
var _useAnnotationRangeSt = (0, _AnnotationRangeContext.useAnnotationRangeState)(),
|
|
39
|
+
hoverDraftDocumentPosition = _useAnnotationRangeSt.hoverDraftDocumentPosition;
|
|
40
|
+
var isDraft = Boolean(enabled && allowAnnotationsDraftMode && hoverDraftDocumentPosition && hoverDraftDocumentPosition.from + 1 === startPos);
|
|
41
|
+
var updateSubscriber = (0, _useInlineCommentSubscriber.useInlineCommentSubscriberContext)();
|
|
42
|
+
var annotationIds = (0, _react.useMemo)(function () {
|
|
43
|
+
var _marks$filter$map;
|
|
44
|
+
return (_marks$filter$map = marks === null || marks === void 0 ? void 0 : marks.filter(function (mark) {
|
|
45
|
+
return mark.type.name === 'annotation';
|
|
46
|
+
}).map(function (mark) {
|
|
47
|
+
return mark.attrs.id;
|
|
48
|
+
})) !== null && _marks$filter$map !== void 0 ? _marks$filter$map : [];
|
|
49
|
+
}, [marks]);
|
|
50
|
+
var activeIds = (0, _useInlineCommentsFilter.useInlineCommentsFilter)({
|
|
51
|
+
annotationIds: annotationIds,
|
|
52
|
+
filter: {
|
|
53
|
+
state: _annotation.AnnotationMarkStates.ACTIVE
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
var _useState = (0, _react.useState)(),
|
|
57
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
58
|
+
focusedId = _useState2[0],
|
|
59
|
+
setFocusedId = _useState2[1];
|
|
60
|
+
var _useState3 = (0, _react.useState)(false),
|
|
61
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
62
|
+
entered = _useState4[0],
|
|
63
|
+
setEntered = _useState4[1];
|
|
64
|
+
var _useAnnotationManager = (0, _AnnotationManagerContext.useAnnotationManagerState)(),
|
|
65
|
+
currentSelectedAnnotationId = _useAnnotationManager.currentSelectedAnnotationId;
|
|
66
|
+
var active = activeIds.some(function (id) {
|
|
67
|
+
return id === focusedId || id === currentSelectedAnnotationId;
|
|
68
|
+
});
|
|
69
|
+
(0, _react.useEffect)(function () {
|
|
70
|
+
if (!updateSubscriber) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
var onFocus = function onFocus(payload) {
|
|
74
|
+
return setFocusedId(payload === null || payload === void 0 ? void 0 : payload.annotationId);
|
|
75
|
+
};
|
|
76
|
+
var onBlur = function onBlur() {
|
|
77
|
+
return setFocusedId(undefined);
|
|
78
|
+
};
|
|
79
|
+
updateSubscriber.on(_types.AnnotationUpdateEvent.SET_ANNOTATION_FOCUS, onFocus);
|
|
80
|
+
updateSubscriber.on(_types.AnnotationUpdateEvent.REMOVE_ANNOTATION_FOCUS, onBlur);
|
|
81
|
+
return function () {
|
|
82
|
+
updateSubscriber.off(_types.AnnotationUpdateEvent.SET_ANNOTATION_FOCUS, onFocus);
|
|
83
|
+
updateSubscriber.off(_types.AnnotationUpdateEvent.REMOVE_ANNOTATION_FOCUS, onBlur);
|
|
84
|
+
};
|
|
85
|
+
}, [updateSubscriber]);
|
|
86
|
+
var onClick = (0, _react.useCallback)(function (event) {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
event.stopPropagation();
|
|
89
|
+
// Anchor the thread to this chart, not an icon inside the badge or a nested renderer.
|
|
90
|
+
var extension = event.currentTarget.closest('.ak-renderer-extension');
|
|
91
|
+
if (extension && activeIds.length) {
|
|
92
|
+
updateSubscriber === null || updateSubscriber === void 0 || updateSubscriber.emit(_types.AnnotationUpdateEvent.ON_ANNOTATION_CLICK, {
|
|
93
|
+
annotationIds: activeIds,
|
|
94
|
+
eventTarget: extension,
|
|
95
|
+
eventTargetType: 'extension',
|
|
96
|
+
viewMethod: _analytics.VIEW_METHOD.BADGE
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}, [activeIds, updateSubscriber]);
|
|
100
|
+
var onMouseEnter = (0, _react.useCallback)(function () {
|
|
101
|
+
return setEntered(true);
|
|
102
|
+
}, []);
|
|
103
|
+
var onMouseLeave = (0, _react.useCallback)(function () {
|
|
104
|
+
return setEntered(false);
|
|
105
|
+
}, []);
|
|
106
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
107
|
+
"data-annotation-draft-mark": isDraft || undefined,
|
|
108
|
+
"data-renderer-mark": isDraft || undefined,
|
|
109
|
+
"data-renderer-start-pos": isDraft ? startPos : undefined,
|
|
110
|
+
className: (0, _runtime.ax)(["_kqswh2mm"])
|
|
111
|
+
}, children, allowAnnotations && annotationIds.map(function (id) {
|
|
112
|
+
return /*#__PURE__*/_react.default.createElement(_annotation2.default, {
|
|
113
|
+
key: id,
|
|
114
|
+
id: id,
|
|
115
|
+
annotationType: _annotation.AnnotationTypes.INLINE_COMMENT,
|
|
116
|
+
annotationParentIds: annotationParentIds,
|
|
117
|
+
allowAnnotations: true,
|
|
118
|
+
useBlockLevel: true,
|
|
119
|
+
isExtension: true,
|
|
120
|
+
dataAttributes: annotationDataAttributes
|
|
121
|
+
});
|
|
122
|
+
}), enabled && activeIds.length > 0 && updateSubscriber && /*#__PURE__*/_react.default.createElement("div", {
|
|
123
|
+
className: (0, _runtime.ax)(["_kqswstnw _154iu2gc _1xi2u2gc"])
|
|
124
|
+
}, /*#__PURE__*/_react.default.createElement(_mediaSingle.CommentBadgeNext, {
|
|
125
|
+
status: active ? 'active' : entered ? 'entered' : 'default',
|
|
126
|
+
onClick: onClick,
|
|
127
|
+
onMouseEnter: onMouseEnter,
|
|
128
|
+
onMouseLeave: onMouseLeave
|
|
129
|
+
})));
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/** Only node-aware provider-approved extensions receive comment visuals. */
|
|
133
|
+
var ExtensionComments = exports.ExtensionComments = function ExtensionComments(props) {
|
|
134
|
+
if (!props.enabled && !props.allowAnnotations) {
|
|
135
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.children);
|
|
136
|
+
}
|
|
137
|
+
return /*#__PURE__*/_react.default.createElement(ExtensionCommentsEnabled, {
|
|
138
|
+
enabled: props.enabled,
|
|
139
|
+
allowAnnotations: props.allowAnnotations,
|
|
140
|
+
allowAnnotationsDraftMode: props.allowAnnotationsDraftMode,
|
|
141
|
+
startPos: props.startPos,
|
|
142
|
+
marks: props.marks
|
|
143
|
+
}, props.children);
|
|
144
|
+
};
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.renderExtension = exports.default = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
12
|
var _react2 = require("@emotion/react");
|
|
12
13
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -14,16 +15,18 @@ var _ui = require("@atlaskit/editor-common/ui");
|
|
|
14
15
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
15
16
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
16
17
|
var _consts = require("../../consts");
|
|
18
|
+
var _context = require("../../ui/annotations/context");
|
|
19
|
+
var _AnnotationHoverContext = require("../../ui/annotations/contexts/AnnotationHoverContext");
|
|
20
|
+
var _AnnotationRangeContext = require("../../ui/annotations/contexts/AnnotationRangeContext");
|
|
17
21
|
var _ExtensionRenderer = _interopRequireDefault(require("../../ui/ExtensionRenderer"));
|
|
18
22
|
var _breakout = require("../utils/breakout");
|
|
23
|
+
var _extensionComments = require("./extension-comments");
|
|
19
24
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
20
|
-
|
|
25
|
+
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; }
|
|
26
|
+
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; } /**
|
|
21
27
|
* @jsxRuntime classic
|
|
22
28
|
* @jsx jsx
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
26
|
-
|
|
29
|
+
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
27
30
|
var FORGE_EXTENSION_TYPE = 'com.atlassian.ecosystem';
|
|
28
31
|
/**
|
|
29
32
|
* Mirrors `FORGE_INLINE_BODIED_PARAM` in `@atlassian/xen-editor-provider`. Duplicated rather than
|
|
@@ -78,7 +81,7 @@ var FireExtensionAsInlineAnalytics = function FireExtensionAsInlineAnalytics(_re
|
|
|
78
81
|
return null;
|
|
79
82
|
};
|
|
80
83
|
var renderExtension = exports.renderExtension = function renderExtension(content, layout) {
|
|
81
|
-
var _node$parameters, _node$parameters2;
|
|
84
|
+
var _node$parameters, _node$parameters2, _options$dataAttribut;
|
|
82
85
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
83
86
|
var removeOverflow = arguments.length > 3 ? arguments[3] : undefined;
|
|
84
87
|
var extensionId = arguments.length > 4 ? arguments[4] : undefined;
|
|
@@ -166,11 +169,17 @@ var renderExtension = exports.renderExtension = function renderExtension(content
|
|
|
166
169
|
},
|
|
167
170
|
"data-layout": layout,
|
|
168
171
|
"data-local-id": localId,
|
|
172
|
+
"data-renderer-start-pos": (_options$dataAttribut = options.dataAttributes) === null || _options$dataAttribut === void 0 ? void 0 : _options$dataAttribut['data-renderer-start-pos'],
|
|
169
173
|
"data-testid": "extension--wrapper",
|
|
170
174
|
"data-node-type": "extension",
|
|
175
|
+
"data-inline-comments-target": options.isCommentTarget || undefined,
|
|
171
176
|
"data-top-level": isTopLevel || undefined,
|
|
172
177
|
"data-forge-inline": isNativeForgeInline || undefined,
|
|
173
|
-
"data-migrated-inline": isMigratedInlineBodied || undefined
|
|
178
|
+
"data-migrated-inline": isMigratedInlineBodied || undefined,
|
|
179
|
+
onBlur: options.onBlur,
|
|
180
|
+
onFocus: options.onFocus,
|
|
181
|
+
onMouseEnter: options.onMouseEnter,
|
|
182
|
+
onMouseLeave: options.onMouseLeave
|
|
174
183
|
}, (0, _react2.jsx)("div", {
|
|
175
184
|
tabIndex: options.tabIndex
|
|
176
185
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
@@ -184,6 +193,7 @@ var renderExtension = exports.renderExtension = function renderExtension(content
|
|
|
184
193
|
}, extensionDiv) : extensionDiv;
|
|
185
194
|
};
|
|
186
195
|
var Extension = function Extension(props) {
|
|
196
|
+
var _providers$inlineComm, _props$dataAttributes;
|
|
187
197
|
var text = props.text,
|
|
188
198
|
_props$layout = props.layout,
|
|
189
199
|
layout = _props$layout === void 0 ? 'default' : _props$layout,
|
|
@@ -196,6 +206,57 @@ var Extension = function Extension(props) {
|
|
|
196
206
|
nodeHeight = props.nodeHeight,
|
|
197
207
|
localId = props.localId,
|
|
198
208
|
isInsideOfInlineExtension = props.isInsideOfInlineExtension;
|
|
209
|
+
var providers = (0, _react.useContext)(_context.ProvidersContext);
|
|
210
|
+
var _useAnnotationRangeDi = (0, _AnnotationRangeContext.useAnnotationRangeDispatch)(),
|
|
211
|
+
setHoverTarget = _useAnnotationRangeDi.setHoverTarget;
|
|
212
|
+
var _useAnnotationHoverDi = (0, _AnnotationHoverContext.useAnnotationHoverDispatch)(),
|
|
213
|
+
cancelTimeout = _useAnnotationHoverDi.cancelTimeout,
|
|
214
|
+
initiateTimeout = _useAnnotationHoverDi.initiateTimeout,
|
|
215
|
+
setIsWithinRange = _useAnnotationHoverDi.setIsWithinRange;
|
|
216
|
+
var isBlockNodeSupported = providers === null || providers === void 0 || (_providers$inlineComm = providers.inlineComment) === null || _providers$inlineComm === void 0 ? void 0 : _providers$inlineComm.isBlockNodeSupported;
|
|
217
|
+
var isCommentTarget = (0, _react.useMemo)(function () {
|
|
218
|
+
return Boolean((0, _fg.fg)('cc_maui_annotations_on_extensions') && props.extensionNode && (isBlockNodeSupported === null || isBlockNodeSupported === void 0 ? void 0 : isBlockNodeSupported(props.extensionNode)) === true);
|
|
219
|
+
}, [props.extensionNode, isBlockNodeSupported]);
|
|
220
|
+
var isFullPageRenderer = props.rendererAppearance === 'full-page' || props.rendererAppearance === 'full-width';
|
|
221
|
+
var onMouseEnter = (0, _react.useCallback)(function (event) {
|
|
222
|
+
cancelTimeout();
|
|
223
|
+
if (event.buttons === 0) {
|
|
224
|
+
setHoverTarget === null || setHoverTarget === void 0 || setHoverTarget(event.currentTarget);
|
|
225
|
+
setIsWithinRange(true);
|
|
226
|
+
}
|
|
227
|
+
}, [cancelTimeout, setHoverTarget, setIsWithinRange]);
|
|
228
|
+
var onMouseLeave = (0, _react.useCallback)(function () {
|
|
229
|
+
return initiateTimeout();
|
|
230
|
+
}, [initiateTimeout]);
|
|
231
|
+
var onFocus = (0, _react.useCallback)(function (event) {
|
|
232
|
+
if (event.currentTarget.contains(event.relatedTarget)) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
cancelTimeout();
|
|
236
|
+
setHoverTarget === null || setHoverTarget === void 0 || setHoverTarget(event.currentTarget);
|
|
237
|
+
setIsWithinRange(true);
|
|
238
|
+
}, [cancelTimeout, setHoverTarget, setIsWithinRange]);
|
|
239
|
+
var onBlur = (0, _react.useCallback)(function (event) {
|
|
240
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
241
|
+
initiateTimeout();
|
|
242
|
+
}
|
|
243
|
+
}, [initiateTimeout]);
|
|
244
|
+
var commentTargetOptions = isCommentTarget && isFullPageRenderer ? {
|
|
245
|
+
isCommentTarget: true,
|
|
246
|
+
onBlur: onBlur,
|
|
247
|
+
onFocus: onFocus,
|
|
248
|
+
onMouseEnter: onMouseEnter,
|
|
249
|
+
onMouseLeave: onMouseLeave
|
|
250
|
+
} : {
|
|
251
|
+
isCommentTarget: isCommentTarget
|
|
252
|
+
};
|
|
253
|
+
var commentProps = {
|
|
254
|
+
enabled: isCommentTarget,
|
|
255
|
+
allowAnnotations: props.allowAnnotations && (0, _fg.fg)('cc_maui_annotations_on_extensions'),
|
|
256
|
+
allowAnnotationsDraftMode: props.allowAnnotationsDraftMode,
|
|
257
|
+
startPos: (_props$dataAttributes = props.dataAttributes) === null || _props$dataAttributes === void 0 ? void 0 : _props$dataAttributes['data-renderer-start-pos'],
|
|
258
|
+
marks: props.marks
|
|
259
|
+
};
|
|
199
260
|
return (0, _react2.jsx)(_ExtensionRenderer.default
|
|
200
261
|
// Ignored via go/ees005
|
|
201
262
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
@@ -208,13 +269,20 @@ var Extension = function Extension(props) {
|
|
|
208
269
|
try {
|
|
209
270
|
// Return the result directly if it's a valid JSX.Element
|
|
210
271
|
if (result && /*#__PURE__*/_react.default.isValidElement(result)) {
|
|
211
|
-
return renderExtension(
|
|
272
|
+
return renderExtension((0, _react2.jsx)(_extensionComments.ExtensionComments, {
|
|
273
|
+
enabled: commentProps.enabled,
|
|
274
|
+
allowAnnotations: commentProps.allowAnnotations,
|
|
275
|
+
allowAnnotationsDraftMode: commentProps.allowAnnotationsDraftMode,
|
|
276
|
+
startPos: commentProps.startPos,
|
|
277
|
+
marks: commentProps.marks
|
|
278
|
+
}, result), layout, _objectSpread({
|
|
279
|
+
dataAttributes: props.dataAttributes,
|
|
212
280
|
isTopLevel: path.length < 1,
|
|
213
281
|
handleRef: handleRef,
|
|
214
282
|
shadowClassNames: shadowClassNames,
|
|
215
283
|
tabIndex: props.tabIndex,
|
|
216
284
|
rendererAppearance: props.rendererAppearance
|
|
217
|
-
}, undefined, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, nodeHeight, localId, undefined, undefined, isInsideOfInlineExtension);
|
|
285
|
+
}, commentTargetOptions), undefined, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, nodeHeight, localId, undefined, undefined, isInsideOfInlineExtension);
|
|
218
286
|
}
|
|
219
287
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
220
288
|
} catch (e) {
|
|
@@ -226,13 +294,20 @@ var Extension = function Extension(props) {
|
|
|
226
294
|
}
|
|
227
295
|
|
|
228
296
|
// Always return default content if anything goes wrong
|
|
229
|
-
return renderExtension(
|
|
297
|
+
return renderExtension((0, _react2.jsx)(_extensionComments.ExtensionComments, {
|
|
298
|
+
enabled: commentProps.enabled,
|
|
299
|
+
allowAnnotations: commentProps.allowAnnotations,
|
|
300
|
+
allowAnnotationsDraftMode: commentProps.allowAnnotationsDraftMode,
|
|
301
|
+
startPos: commentProps.startPos,
|
|
302
|
+
marks: commentProps.marks
|
|
303
|
+
}, text || 'extension'), layout, _objectSpread({
|
|
304
|
+
dataAttributes: props.dataAttributes,
|
|
230
305
|
isTopLevel: path.length < 1,
|
|
231
306
|
handleRef: handleRef,
|
|
232
307
|
shadowClassNames: shadowClassNames,
|
|
233
308
|
tabIndex: props.tabIndex,
|
|
234
309
|
rendererAppearance: props.rendererAppearance
|
|
235
|
-
}, undefined, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, nodeHeight, localId, undefined, undefined, isInsideOfInlineExtension);
|
|
310
|
+
}, commentTargetOptions), undefined, parameters === null || parameters === void 0 ? void 0 : parameters.extensionId, extensionViewportSizes, nodeHeight, localId, undefined, undefined, isInsideOfInlineExtension);
|
|
236
311
|
});
|
|
237
312
|
};
|
|
238
313
|
var _default_1 = (0, _ui.overflowShadow)(Extension, {
|
package/dist/cjs/steps/index.js
CHANGED
|
@@ -226,11 +226,34 @@ function resolvePos(node, offset) {
|
|
|
226
226
|
}
|
|
227
227
|
return resolvedPos + offset;
|
|
228
228
|
}
|
|
229
|
+
function getSelectedCommentTargetPosition(range) {
|
|
230
|
+
var startContainer = range.startContainer,
|
|
231
|
+
startOffset = range.startOffset,
|
|
232
|
+
endContainer = range.endContainer,
|
|
233
|
+
endOffset = range.endOffset;
|
|
234
|
+
if (startContainer !== endContainer || endOffset !== startOffset + 1) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
var selectedNode = startContainer.childNodes[startOffset];
|
|
238
|
+
if (!selectedNode || !isElementNode(selectedNode) || selectedNode.dataset.inlineCommentsTarget !== 'true' || !isPositionPointer(selectedNode)) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Subtract 1 from the renderer start position to get the position before the extension node.
|
|
243
|
+
return getStartPos(selectedNode) - 1;
|
|
244
|
+
}
|
|
229
245
|
function getPosFromRange(range) {
|
|
230
246
|
var startContainer = range.startContainer,
|
|
231
247
|
startOffset = range.startOffset,
|
|
232
248
|
endContainer = range.endContainer,
|
|
233
249
|
endOffset = range.endOffset;
|
|
250
|
+
var selectedCommentTargetPosition = (0, _fg.fg)('cc_maui_annotations_on_extensions') && getSelectedCommentTargetPosition(range);
|
|
251
|
+
if (selectedCommentTargetPosition !== false) {
|
|
252
|
+
return {
|
|
253
|
+
from: selectedCommentTargetPosition,
|
|
254
|
+
to: selectedCommentTargetPosition
|
|
255
|
+
};
|
|
256
|
+
}
|
|
234
257
|
var possibleMediaOrMediaSingleElement = findParent(startContainer);
|
|
235
258
|
|
|
236
259
|
// Video hover targets return media single, not media, thus, the extra check in condition.
|
package/dist/cjs/ui/Expand.js
CHANGED
|
@@ -17,6 +17,7 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
17
17
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
18
18
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
19
19
|
var _chevronRight = _interopRequireDefault(require("@atlaskit/icon/core/chevron-right"));
|
|
20
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
20
21
|
var _Tooltip = _interopRequireDefault(require("@atlaskit/tooltip/Tooltip"));
|
|
21
22
|
var _events = require("../analytics/events");
|
|
22
23
|
var _activeHeaderIdProvider = require("./active-header-id-provider");
|
|
@@ -403,10 +404,19 @@ function Expand(_ref) {
|
|
|
403
404
|
e.preventDefault();
|
|
404
405
|
e.stopPropagation();
|
|
405
406
|
fireExpandToggleAnalytics(nodeType, expanded, fireAnalyticsEvent);
|
|
407
|
+
// Recorded so a product remounting this expand under its own body gets it back as the
|
|
408
|
+
// reader left it.
|
|
409
|
+
var recordsToggle = node !== undefined && (0, _isExperimentEnabled.isExperimentEnabled)('cc_light_mode_table_virtualization');
|
|
406
410
|
if (expanded) {
|
|
407
411
|
setExpanded(false);
|
|
412
|
+
if (recordsToggle) {
|
|
413
|
+
revealedByFind.delete(node);
|
|
414
|
+
}
|
|
408
415
|
} else {
|
|
409
416
|
openBody();
|
|
417
|
+
if (recordsToggle) {
|
|
418
|
+
revealedByFind.add(node);
|
|
419
|
+
}
|
|
410
420
|
}
|
|
411
421
|
e.persist();
|
|
412
422
|
// @ts-ignore detail doesn't exist on type
|
|
@@ -72,7 +72,7 @@ var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
72
72
|
var TABLE_INFO_TIMEOUT = 10000;
|
|
73
73
|
var RENDER_EVENT_SAMPLE_RATE = 0.1;
|
|
74
74
|
var packageName = "@atlaskit/renderer";
|
|
75
|
-
var packageVersion = "148.0
|
|
75
|
+
var packageVersion = "148.1.0";
|
|
76
76
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
77
77
|
containerName: 'ak-renderer-wrapper',
|
|
78
78
|
containerType: 'inline-size'
|