@atlaskit/renderer 109.18.1 → 109.19.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 +16 -0
- package/dist/cjs/react/nodes/media/index.js +11 -5
- package/dist/cjs/react/nodes/mediaSingle/index.js +21 -7
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/cjs/ui/annotations/contexts/AnnotationHoverContext.js +63 -0
- package/dist/cjs/ui/annotations/hover/mounter.js +2 -0
- package/dist/cjs/ui/annotations/hover/range-validator.js +4 -0
- package/dist/cjs/ui/annotations/index.js +3 -2
- package/dist/es2019/react/nodes/media/index.js +8 -4
- package/dist/es2019/react/nodes/mediaSingle/index.js +22 -7
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/es2019/ui/annotations/contexts/AnnotationHoverContext.js +46 -0
- package/dist/es2019/ui/annotations/hover/mounter.js +2 -0
- package/dist/es2019/ui/annotations/hover/range-validator.js +5 -0
- package/dist/es2019/ui/annotations/index.js +3 -2
- package/dist/esm/react/nodes/media/index.js +11 -5
- package/dist/esm/react/nodes/mediaSingle/index.js +21 -7
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/esm/ui/annotations/contexts/AnnotationHoverContext.js +53 -0
- package/dist/esm/ui/annotations/hover/mounter.js +2 -0
- package/dist/esm/ui/annotations/hover/range-validator.js +4 -0
- package/dist/esm/ui/annotations/index.js +3 -2
- package/dist/types/react/nodes/media/index.d.ts +1 -0
- package/dist/types/ui/annotations/contexts/AnnotationHoverContext.d.ts +14 -0
- package/dist/types/ui/annotations/hover/mounter.d.ts +1 -0
- package/dist/types-ts4.5/react/nodes/media/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/annotations/contexts/AnnotationHoverContext.d.ts +14 -0
- package/dist/types-ts4.5/ui/annotations/hover/mounter.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 109.19.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#91808](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91808) [`00e5dcfdf240`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/00e5dcfdf240) - [ux] Does not add comment button on hover on media that is inside comment or inline comment rendereres
|
|
8
|
+
|
|
9
|
+
## 109.19.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#90964](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/90964) [`6e7df33eb280`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6e7df33eb280) - [ux] [ED-22992] Auto-dismiss comment button on media if mouse rolling away from media and comment popup, remove popup position transition so that popup does not appear sliding across the page when mouse moving from one media to another
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 109.18.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -35,7 +35,7 @@ var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
|
35
35
|
var _reactIntlNext = require("react-intl-next");
|
|
36
36
|
var _hooks = require("../../../ui/annotations/hooks");
|
|
37
37
|
var _types = require("@atlaskit/editor-common/types");
|
|
38
|
-
var _excluded = ["marks", "mediaElement"];
|
|
38
|
+
var _excluded = ["marks", "mediaElement", "isDrafting"];
|
|
39
39
|
/** @jsx jsx */
|
|
40
40
|
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); }
|
|
41
41
|
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 && Object.prototype.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; }
|
|
@@ -121,6 +121,8 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref5) {
|
|
|
121
121
|
var _marks$map;
|
|
122
122
|
var marks = _ref5.marks,
|
|
123
123
|
mediaElement = _ref5.mediaElement,
|
|
124
|
+
_ref5$isDrafting = _ref5.isDrafting,
|
|
125
|
+
isDrafting = _ref5$isDrafting === void 0 ? false : _ref5$isDrafting,
|
|
124
126
|
rest = (0, _objectWithoutProperties2.default)(_ref5, _excluded);
|
|
125
127
|
var _useState = (0, _react.useState)('default'),
|
|
126
128
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -160,7 +162,7 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref5) {
|
|
|
160
162
|
observer.disconnect();
|
|
161
163
|
};
|
|
162
164
|
}, [mediaElement, setStatus]);
|
|
163
|
-
if (!activeParentIds.length) {
|
|
165
|
+
if (!isDrafting && !activeParentIds.length) {
|
|
164
166
|
return null;
|
|
165
167
|
}
|
|
166
168
|
var onClick = function onClick(e) {
|
|
@@ -201,7 +203,9 @@ var Media = /*#__PURE__*/function (_PureComponent) {
|
|
|
201
203
|
ssr = _this$props.ssr,
|
|
202
204
|
width = _this$props.width,
|
|
203
205
|
height = _this$props.height,
|
|
204
|
-
mediaSingleElement = _this$props.mediaSingleElement
|
|
206
|
+
mediaSingleElement = _this$props.mediaSingleElement,
|
|
207
|
+
_this$props$isDraftin = _this$props.isDrafting,
|
|
208
|
+
isDrafting = _this$props$isDraftin === void 0 ? false : _this$props$isDraftin;
|
|
205
209
|
var annotationMarks = _this.props.isAnnotationMark ? _this.props.marks.filter(_this.props.isAnnotationMark) : undefined;
|
|
206
210
|
var borderMark = _this.props.marks.find(_this.props.isBorderMark);
|
|
207
211
|
var linkMark = _this.props.marks.find(_this.props.isLinkMark);
|
|
@@ -223,7 +227,8 @@ var Media = /*#__PURE__*/function (_PureComponent) {
|
|
|
223
227
|
marks: annotationMarks,
|
|
224
228
|
mediaElement: mediaSingleElement,
|
|
225
229
|
width: width,
|
|
226
|
-
height: height
|
|
230
|
+
height: height,
|
|
231
|
+
isDrafting: isDrafting
|
|
227
232
|
}), (0, _react2.jsx)(_MediaCard.MediaCard, (0, _extends2.default)({
|
|
228
233
|
contextIdentifierProvider: contextIdentifierProvider
|
|
229
234
|
}, _this.props, {
|
|
@@ -311,7 +316,8 @@ var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
|
311
316
|
}) : dataAttributes;
|
|
312
317
|
}, [applyDraftAnnotation, dataAttributes]);
|
|
313
318
|
return (0, _react2.jsx)(Media, (0, _extends2.default)({}, props, {
|
|
314
|
-
dataAttributes: dataAttributesWithDraftAnnotation
|
|
319
|
+
dataAttributes: dataAttributesWithDraftAnnotation,
|
|
320
|
+
isDrafting: shouldApplyDraftAnnotation
|
|
315
321
|
}));
|
|
316
322
|
};
|
|
317
323
|
var _default = exports.default = MediaWithDraftAnnotation;
|
|
@@ -16,6 +16,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
16
16
|
var _style = require("../../../ui/Renderer/style");
|
|
17
17
|
var _styles = require("./styles");
|
|
18
18
|
var _AnnotationRangeContext = require("../../../ui/annotations/contexts/AnnotationRangeContext");
|
|
19
|
+
var _AnnotationHoverContext = require("../../../ui/annotations/contexts/AnnotationHoverContext");
|
|
19
20
|
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); }
|
|
20
21
|
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 && Object.prototype.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; }
|
|
21
22
|
/** @jsx jsx */
|
|
@@ -113,8 +114,9 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
|
|
|
113
114
|
|
|
114
115
|
// TODO: put appearance-based padding into theme instead
|
|
115
116
|
|
|
116
|
-
var
|
|
117
|
+
var isFullPage = rendererAppearance === 'full-page';
|
|
117
118
|
var isFullWidth = rendererAppearance === 'full-width';
|
|
119
|
+
var padding = isFullPage ? _style.FullPagePadding * 2 : 0;
|
|
118
120
|
var calcDimensions = (0, _react.useCallback)(function (mediaContainerWidth) {
|
|
119
121
|
var containerWidth = getMediaContainerWidth(mediaContainerWidth, layout);
|
|
120
122
|
var maxWidth = containerWidth;
|
|
@@ -147,22 +149,34 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
|
|
|
147
149
|
}, [height, width]);
|
|
148
150
|
var _useAnnotationRangeDi = (0, _AnnotationRangeContext.useAnnotationRangeDispatch)(),
|
|
149
151
|
setHoverTarget = _useAnnotationRangeDi.setHoverTarget;
|
|
152
|
+
var _useAnnotationHoverDi = (0, _AnnotationHoverContext.useAnnotationHoverDispatch)(),
|
|
153
|
+
cancelTimeout = _useAnnotationHoverDi.cancelTimeout,
|
|
154
|
+
initiateTimeout = _useAnnotationHoverDi.initiateTimeout,
|
|
155
|
+
setIsWithinRange = _useAnnotationHoverDi.setIsWithinRange;
|
|
156
|
+
var isFullPageRenderer = isFullPage || isFullWidth;
|
|
150
157
|
(0, _react.useEffect)(function () {
|
|
151
158
|
var mediaSingleElement = ref.current;
|
|
152
|
-
var
|
|
159
|
+
var handleMouseEnter = function handleMouseEnter(event) {
|
|
160
|
+
cancelTimeout();
|
|
153
161
|
if (event.buttons === 0) {
|
|
154
162
|
setHoverTarget && setHoverTarget(event.target);
|
|
163
|
+
setIsWithinRange(true);
|
|
155
164
|
}
|
|
156
165
|
};
|
|
157
|
-
|
|
158
|
-
|
|
166
|
+
var handleMouseLeave = function handleMouseLeave() {
|
|
167
|
+
initiateTimeout();
|
|
168
|
+
};
|
|
169
|
+
if (mediaSingleElement && isFullPageRenderer) {
|
|
170
|
+
mediaSingleElement.addEventListener('mouseenter', handleMouseEnter);
|
|
171
|
+
mediaSingleElement.addEventListener('mouseleave', handleMouseLeave);
|
|
159
172
|
}
|
|
160
173
|
return function () {
|
|
161
|
-
if (mediaSingleElement) {
|
|
162
|
-
mediaSingleElement.removeEventListener('mouseenter',
|
|
174
|
+
if (mediaSingleElement && isFullPageRenderer) {
|
|
175
|
+
mediaSingleElement.removeEventListener('mouseenter', handleMouseEnter);
|
|
176
|
+
mediaSingleElement.removeEventListener('mouseleave', handleMouseLeave);
|
|
163
177
|
}
|
|
164
178
|
};
|
|
165
|
-
}, [setHoverTarget]);
|
|
179
|
+
}, [setHoverTarget, isFullPageRenderer, cancelTimeout, initiateTimeout, setIsWithinRange]);
|
|
166
180
|
|
|
167
181
|
// Note: in SSR mode the `window` object is not defined,
|
|
168
182
|
// therefore width here is 0, see:
|
|
@@ -55,7 +55,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
55
55
|
var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
56
56
|
var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
57
57
|
var packageName = "@atlaskit/renderer";
|
|
58
|
-
var packageVersion = "109.
|
|
58
|
+
var packageVersion = "109.19.1";
|
|
59
59
|
var Renderer = exports.Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
60
60
|
(0, _inherits2.default)(Renderer, _PureComponent);
|
|
61
61
|
var _super = _createSuper(Renderer);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useAnnotationHoverDispatch = exports.useAnnotationHoverContext = exports.AnnotationHoverContext = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
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); }
|
|
12
|
+
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 && Object.prototype.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; }
|
|
13
|
+
var AnnotationHoverStateContext = /*#__PURE__*/(0, _react.createContext)({
|
|
14
|
+
isWithinRange: false
|
|
15
|
+
});
|
|
16
|
+
var AnnotationHoverDispatchContext = /*#__PURE__*/(0, _react.createContext)({
|
|
17
|
+
cancelTimeout: function cancelTimeout() {},
|
|
18
|
+
initiateTimeout: function initiateTimeout() {},
|
|
19
|
+
setIsWithinRange: function setIsWithinRange() {}
|
|
20
|
+
});
|
|
21
|
+
var AnnotationHoverContext = exports.AnnotationHoverContext = function AnnotationHoverContext(_ref) {
|
|
22
|
+
var children = _ref.children;
|
|
23
|
+
var _useState = (0, _react.useState)(false),
|
|
24
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
25
|
+
isWithinRange = _useState2[0],
|
|
26
|
+
setIsWithinRange = _useState2[1];
|
|
27
|
+
var timeoutHandler = (0, _react.useRef)();
|
|
28
|
+
var cancelTimeout = (0, _react.useCallback)(function () {
|
|
29
|
+
if (timeoutHandler) {
|
|
30
|
+
clearTimeout(timeoutHandler.current);
|
|
31
|
+
}
|
|
32
|
+
}, [timeoutHandler]);
|
|
33
|
+
var initiateTimeout = (0, _react.useCallback)(function () {
|
|
34
|
+
if (isWithinRange) {
|
|
35
|
+
timeoutHandler.current = setTimeout(function () {
|
|
36
|
+
setIsWithinRange(false);
|
|
37
|
+
}, 500);
|
|
38
|
+
}
|
|
39
|
+
}, [isWithinRange]);
|
|
40
|
+
var stateData = (0, _react.useMemo)(function () {
|
|
41
|
+
return {
|
|
42
|
+
isWithinRange: isWithinRange
|
|
43
|
+
};
|
|
44
|
+
}, [isWithinRange]);
|
|
45
|
+
var dispatchData = (0, _react.useMemo)(function () {
|
|
46
|
+
return {
|
|
47
|
+
cancelTimeout: cancelTimeout,
|
|
48
|
+
initiateTimeout: initiateTimeout,
|
|
49
|
+
setIsWithinRange: setIsWithinRange
|
|
50
|
+
};
|
|
51
|
+
}, [cancelTimeout, initiateTimeout, setIsWithinRange]);
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement(AnnotationHoverStateContext.Provider, {
|
|
53
|
+
value: stateData
|
|
54
|
+
}, /*#__PURE__*/_react.default.createElement(AnnotationHoverDispatchContext.Provider, {
|
|
55
|
+
value: dispatchData
|
|
56
|
+
}, children));
|
|
57
|
+
};
|
|
58
|
+
var useAnnotationHoverContext = exports.useAnnotationHoverContext = function useAnnotationHoverContext() {
|
|
59
|
+
return (0, _react.useContext)(AnnotationHoverStateContext);
|
|
60
|
+
};
|
|
61
|
+
var useAnnotationHoverDispatch = exports.useAnnotationHoverDispatch = function useAnnotationHoverDispatch() {
|
|
62
|
+
return (0, _react.useContext)(AnnotationHoverDispatchContext);
|
|
63
|
+
};
|
|
@@ -18,6 +18,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
18
18
|
var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props) {
|
|
19
19
|
var Component = props.component,
|
|
20
20
|
range = props.range,
|
|
21
|
+
isWithinRange = props.isWithinRange,
|
|
21
22
|
isAnnotationAllowed = props.isAnnotationAllowed,
|
|
22
23
|
wrapperDOM = props.wrapperDOM,
|
|
23
24
|
onCloseProps = props.onClose,
|
|
@@ -123,6 +124,7 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
|
|
|
123
124
|
}, [onCloseProps, removeDraftModeCallback, createAnalyticsEvent]);
|
|
124
125
|
return /*#__PURE__*/_react.default.createElement(Component, {
|
|
125
126
|
range: range,
|
|
127
|
+
isWithinRange: isWithinRange,
|
|
126
128
|
wrapperDOM: wrapperDOM.current,
|
|
127
129
|
isAnnotationAllowed: isAnnotationAllowed,
|
|
128
130
|
onClose: onCloseCallback,
|
|
@@ -9,6 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _mounter = require("./mounter");
|
|
10
10
|
var _RendererActionsContext = require("../../RendererActionsContext");
|
|
11
11
|
var _AnnotationRangeContext = require("../contexts/AnnotationRangeContext");
|
|
12
|
+
var _AnnotationHoverContext = require("../contexts/AnnotationHoverContext");
|
|
12
13
|
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); }
|
|
13
14
|
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 && Object.prototype.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; }
|
|
14
15
|
var RangeValidator = exports.RangeValidator = function RangeValidator(props) {
|
|
@@ -23,11 +24,14 @@ var RangeValidator = exports.RangeValidator = function RangeValidator(props) {
|
|
|
23
24
|
var _useAnnotationRangeSt = (0, _AnnotationRangeContext.useAnnotationRangeState)(),
|
|
24
25
|
range = _useAnnotationRangeSt.range,
|
|
25
26
|
type = _useAnnotationRangeSt.type;
|
|
27
|
+
var _useAnnotationHoverCo = (0, _AnnotationHoverContext.useAnnotationHoverContext)(),
|
|
28
|
+
isWithinRange = _useAnnotationHoverCo.isWithinRange;
|
|
26
29
|
if (!range || type !== 'hover') {
|
|
27
30
|
return null;
|
|
28
31
|
}
|
|
29
32
|
var documentPosition = actions.getPositionFromRange(range);
|
|
30
33
|
return /*#__PURE__*/_react.default.createElement(_mounter.Mounter, {
|
|
34
|
+
isWithinRange: isWithinRange,
|
|
31
35
|
range: range,
|
|
32
36
|
wrapperDOM: rendererRef,
|
|
33
37
|
component: component,
|
|
@@ -26,6 +26,7 @@ var _useLoadAnnotations = require("./hooks/use-load-annotations");
|
|
|
26
26
|
var _useEvents = require("./hooks/use-events");
|
|
27
27
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
28
28
|
var _AnnotationRangeContext = require("./contexts/AnnotationRangeContext");
|
|
29
|
+
var _AnnotationHoverContext = require("./contexts/AnnotationHoverContext");
|
|
29
30
|
var _draft = require("./draft");
|
|
30
31
|
var _element = require("./element");
|
|
31
32
|
var LoadAnnotations = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
@@ -54,12 +55,12 @@ var AnnotationsWrapper = exports.AnnotationsWrapper = function AnnotationsWrappe
|
|
|
54
55
|
value: inlineCommentAnnotationsState
|
|
55
56
|
}, /*#__PURE__*/_react.default.createElement(_AnnotationRangeContext.AnnotationRangeProvider, {
|
|
56
57
|
allowCommentsOnMedia: (_annotationProvider$i = annotationProvider === null || annotationProvider === void 0 || (_annotationProvider$i2 = annotationProvider.inlineComment) === null || _annotationProvider$i2 === void 0 ? void 0 : _annotationProvider$i2.allowCommentsOnMedia) !== null && _annotationProvider$i !== void 0 ? _annotationProvider$i : false
|
|
57
|
-
}, /*#__PURE__*/_react.default.createElement(_wrapper.AnnotationsContextWrapper, {
|
|
58
|
+
}, /*#__PURE__*/_react.default.createElement(_AnnotationHoverContext.AnnotationHoverContext, null, /*#__PURE__*/_react.default.createElement(_wrapper.AnnotationsContextWrapper, {
|
|
58
59
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
59
60
|
rendererRef: rendererRef
|
|
60
61
|
}, /*#__PURE__*/_react.default.createElement(LoadAnnotations, {
|
|
61
62
|
adfDocument: adfDocument
|
|
62
63
|
}), /*#__PURE__*/_react.default.createElement(_view.AnnotationView, {
|
|
63
64
|
createAnalyticsEvent: createAnalyticsEvent
|
|
64
|
-
}), children))));
|
|
65
|
+
}), children)))));
|
|
65
66
|
};
|
|
@@ -101,6 +101,7 @@ const CommentBadge = injectIntl(CommentBadgeComponent);
|
|
|
101
101
|
const CommentBadgeWrapper = ({
|
|
102
102
|
marks,
|
|
103
103
|
mediaElement,
|
|
104
|
+
isDrafting = false,
|
|
104
105
|
...rest
|
|
105
106
|
}) => {
|
|
106
107
|
var _marks$map;
|
|
@@ -134,7 +135,7 @@ const CommentBadgeWrapper = ({
|
|
|
134
135
|
observer.disconnect();
|
|
135
136
|
};
|
|
136
137
|
}, [mediaElement, setStatus]);
|
|
137
|
-
if (!activeParentIds.length) {
|
|
138
|
+
if (!isDrafting && !activeParentIds.length) {
|
|
138
139
|
return null;
|
|
139
140
|
}
|
|
140
141
|
const onClick = e => {
|
|
@@ -168,7 +169,8 @@ class Media extends PureComponent {
|
|
|
168
169
|
ssr,
|
|
169
170
|
width,
|
|
170
171
|
height,
|
|
171
|
-
mediaSingleElement
|
|
172
|
+
mediaSingleElement,
|
|
173
|
+
isDrafting = false
|
|
172
174
|
} = this.props;
|
|
173
175
|
const annotationMarks = this.props.isAnnotationMark ? this.props.marks.filter(this.props.isAnnotationMark) : undefined;
|
|
174
176
|
const borderMark = this.props.marks.find(this.props.isBorderMark);
|
|
@@ -193,7 +195,8 @@ class Media extends PureComponent {
|
|
|
193
195
|
marks: annotationMarks,
|
|
194
196
|
mediaElement: mediaSingleElement,
|
|
195
197
|
width: width,
|
|
196
|
-
height: height
|
|
198
|
+
height: height,
|
|
199
|
+
isDrafting: isDrafting
|
|
197
200
|
}), jsx(MediaCard, _extends({
|
|
198
201
|
contextIdentifierProvider: contextIdentifierProvider
|
|
199
202
|
}, this.props, {
|
|
@@ -274,7 +277,8 @@ const MediaWithDraftAnnotation = props => {
|
|
|
274
277
|
'data-renderer-mark': true
|
|
275
278
|
} : dataAttributes, [applyDraftAnnotation, dataAttributes]);
|
|
276
279
|
return jsx(Media, _extends({}, props, {
|
|
277
|
-
dataAttributes: dataAttributesWithDraftAnnotation
|
|
280
|
+
dataAttributes: dataAttributesWithDraftAnnotation,
|
|
281
|
+
isDrafting: shouldApplyDraftAnnotation
|
|
278
282
|
}));
|
|
279
283
|
};
|
|
280
284
|
export default MediaWithDraftAnnotation;
|
|
@@ -9,6 +9,7 @@ import { akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth, akEditorWideL
|
|
|
9
9
|
import { FullPagePadding } from '../../../ui/Renderer/style';
|
|
10
10
|
import { uiMediaSingleBaseStyles, uiMediaSingleLayoutStyles } from './styles';
|
|
11
11
|
import { useAnnotationRangeDispatch } from '../../../ui/annotations/contexts/AnnotationRangeContext';
|
|
12
|
+
import { useAnnotationHoverDispatch } from '../../../ui/annotations/contexts/AnnotationHoverContext';
|
|
12
13
|
const DEFAULT_WIDTH = 250;
|
|
13
14
|
const DEFAULT_HEIGHT = 200;
|
|
14
15
|
const isMediaElement = media => {
|
|
@@ -100,8 +101,9 @@ const MediaSingleWithChildren = props => {
|
|
|
100
101
|
|
|
101
102
|
// TODO: put appearance-based padding into theme instead
|
|
102
103
|
|
|
103
|
-
const
|
|
104
|
+
const isFullPage = rendererAppearance === 'full-page';
|
|
104
105
|
const isFullWidth = rendererAppearance === 'full-width';
|
|
106
|
+
const padding = isFullPage ? FullPagePadding * 2 : 0;
|
|
105
107
|
const calcDimensions = useCallback(mediaContainerWidth => {
|
|
106
108
|
const containerWidth = getMediaContainerWidth(mediaContainerWidth, layout);
|
|
107
109
|
const maxWidth = containerWidth;
|
|
@@ -133,22 +135,35 @@ const MediaSingleWithChildren = props => {
|
|
|
133
135
|
const {
|
|
134
136
|
setHoverTarget
|
|
135
137
|
} = useAnnotationRangeDispatch();
|
|
138
|
+
const {
|
|
139
|
+
cancelTimeout,
|
|
140
|
+
initiateTimeout,
|
|
141
|
+
setIsWithinRange
|
|
142
|
+
} = useAnnotationHoverDispatch();
|
|
143
|
+
const isFullPageRenderer = isFullPage || isFullWidth;
|
|
136
144
|
useEffect(() => {
|
|
137
145
|
const mediaSingleElement = ref.current;
|
|
138
|
-
const
|
|
146
|
+
const handleMouseEnter = event => {
|
|
147
|
+
cancelTimeout();
|
|
139
148
|
if (event.buttons === 0) {
|
|
140
149
|
setHoverTarget && setHoverTarget(event.target);
|
|
150
|
+
setIsWithinRange(true);
|
|
141
151
|
}
|
|
142
152
|
};
|
|
143
|
-
|
|
144
|
-
|
|
153
|
+
const handleMouseLeave = () => {
|
|
154
|
+
initiateTimeout();
|
|
155
|
+
};
|
|
156
|
+
if (mediaSingleElement && isFullPageRenderer) {
|
|
157
|
+
mediaSingleElement.addEventListener('mouseenter', handleMouseEnter);
|
|
158
|
+
mediaSingleElement.addEventListener('mouseleave', handleMouseLeave);
|
|
145
159
|
}
|
|
146
160
|
return () => {
|
|
147
|
-
if (mediaSingleElement) {
|
|
148
|
-
mediaSingleElement.removeEventListener('mouseenter',
|
|
161
|
+
if (mediaSingleElement && isFullPageRenderer) {
|
|
162
|
+
mediaSingleElement.removeEventListener('mouseenter', handleMouseEnter);
|
|
163
|
+
mediaSingleElement.removeEventListener('mouseleave', handleMouseLeave);
|
|
149
164
|
}
|
|
150
165
|
};
|
|
151
|
-
}, [setHoverTarget]);
|
|
166
|
+
}, [setHoverTarget, isFullPageRenderer, cancelTimeout, initiateTimeout, setIsWithinRange]);
|
|
152
167
|
|
|
153
168
|
// Note: in SSR mode the `window` object is not defined,
|
|
154
169
|
// therefore width here is 0, see:
|
|
@@ -36,7 +36,7 @@ import { EditorMediaClientProvider } from '../../react/utils/EditorMediaClientPr
|
|
|
36
36
|
export const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
37
37
|
export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
38
38
|
const packageName = "@atlaskit/renderer";
|
|
39
|
-
const packageVersion = "109.
|
|
39
|
+
const packageVersion = "109.19.1";
|
|
40
40
|
export class Renderer extends PureComponent {
|
|
41
41
|
constructor(props) {
|
|
42
42
|
super(props);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { createContext, useState, useContext, useMemo, useRef, useCallback } from 'react';
|
|
2
|
+
const AnnotationHoverStateContext = /*#__PURE__*/createContext({
|
|
3
|
+
isWithinRange: false
|
|
4
|
+
});
|
|
5
|
+
const AnnotationHoverDispatchContext = /*#__PURE__*/createContext({
|
|
6
|
+
cancelTimeout: () => {},
|
|
7
|
+
initiateTimeout: () => {},
|
|
8
|
+
setIsWithinRange: () => {}
|
|
9
|
+
});
|
|
10
|
+
export const AnnotationHoverContext = ({
|
|
11
|
+
children
|
|
12
|
+
}) => {
|
|
13
|
+
const [isWithinRange, setIsWithinRange] = useState(false);
|
|
14
|
+
const timeoutHandler = useRef();
|
|
15
|
+
const cancelTimeout = useCallback(() => {
|
|
16
|
+
if (timeoutHandler) {
|
|
17
|
+
clearTimeout(timeoutHandler.current);
|
|
18
|
+
}
|
|
19
|
+
}, [timeoutHandler]);
|
|
20
|
+
const initiateTimeout = useCallback(() => {
|
|
21
|
+
if (isWithinRange) {
|
|
22
|
+
timeoutHandler.current = setTimeout(() => {
|
|
23
|
+
setIsWithinRange(false);
|
|
24
|
+
}, 500);
|
|
25
|
+
}
|
|
26
|
+
}, [isWithinRange]);
|
|
27
|
+
const stateData = useMemo(() => ({
|
|
28
|
+
isWithinRange
|
|
29
|
+
}), [isWithinRange]);
|
|
30
|
+
const dispatchData = useMemo(() => ({
|
|
31
|
+
cancelTimeout,
|
|
32
|
+
initiateTimeout,
|
|
33
|
+
setIsWithinRange
|
|
34
|
+
}), [cancelTimeout, initiateTimeout, setIsWithinRange]);
|
|
35
|
+
return /*#__PURE__*/React.createElement(AnnotationHoverStateContext.Provider, {
|
|
36
|
+
value: stateData
|
|
37
|
+
}, /*#__PURE__*/React.createElement(AnnotationHoverDispatchContext.Provider, {
|
|
38
|
+
value: dispatchData
|
|
39
|
+
}, children));
|
|
40
|
+
};
|
|
41
|
+
export const useAnnotationHoverContext = () => {
|
|
42
|
+
return useContext(AnnotationHoverStateContext);
|
|
43
|
+
};
|
|
44
|
+
export const useAnnotationHoverDispatch = () => {
|
|
45
|
+
return useContext(AnnotationHoverDispatchContext);
|
|
46
|
+
};
|
|
@@ -8,6 +8,7 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
|
|
|
8
8
|
const {
|
|
9
9
|
component: Component,
|
|
10
10
|
range,
|
|
11
|
+
isWithinRange,
|
|
11
12
|
isAnnotationAllowed,
|
|
12
13
|
wrapperDOM,
|
|
13
14
|
onClose: onCloseProps,
|
|
@@ -110,6 +111,7 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
|
|
|
110
111
|
}, [onCloseProps, removeDraftModeCallback, createAnalyticsEvent]);
|
|
111
112
|
return /*#__PURE__*/React.createElement(Component, {
|
|
112
113
|
range: range,
|
|
114
|
+
isWithinRange: isWithinRange,
|
|
113
115
|
wrapperDOM: wrapperDOM.current,
|
|
114
116
|
isAnnotationAllowed: isAnnotationAllowed,
|
|
115
117
|
onClose: onCloseCallback,
|
|
@@ -2,6 +2,7 @@ import React, { useContext } from 'react';
|
|
|
2
2
|
import { Mounter } from './mounter';
|
|
3
3
|
import { RendererContext as ActionsContext } from '../../RendererActionsContext';
|
|
4
4
|
import { useAnnotationRangeDispatch, useAnnotationRangeState } from '../contexts/AnnotationRangeContext';
|
|
5
|
+
import { useAnnotationHoverContext } from '../contexts/AnnotationHoverContext';
|
|
5
6
|
export const RangeValidator = props => {
|
|
6
7
|
const {
|
|
7
8
|
component,
|
|
@@ -18,11 +19,15 @@ export const RangeValidator = props => {
|
|
|
18
19
|
range,
|
|
19
20
|
type
|
|
20
21
|
} = useAnnotationRangeState();
|
|
22
|
+
const {
|
|
23
|
+
isWithinRange
|
|
24
|
+
} = useAnnotationHoverContext();
|
|
21
25
|
if (!range || type !== 'hover') {
|
|
22
26
|
return null;
|
|
23
27
|
}
|
|
24
28
|
const documentPosition = actions.getPositionFromRange(range);
|
|
25
29
|
return /*#__PURE__*/React.createElement(Mounter, {
|
|
30
|
+
isWithinRange: isWithinRange,
|
|
26
31
|
range: range,
|
|
27
32
|
wrapperDOM: rendererRef,
|
|
28
33
|
component: component,
|
|
@@ -7,6 +7,7 @@ import { useLoadAnnotations } from './hooks/use-load-annotations';
|
|
|
7
7
|
import { useAnnotationStateByTypeEvent } from './hooks/use-events';
|
|
8
8
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
9
9
|
import { AnnotationRangeProvider } from './contexts/AnnotationRangeContext';
|
|
10
|
+
import { AnnotationHoverContext } from './contexts/AnnotationHoverContext';
|
|
10
11
|
const LoadAnnotations = /*#__PURE__*/React.memo(({
|
|
11
12
|
adfDocument
|
|
12
13
|
}) => {
|
|
@@ -37,14 +38,14 @@ export const AnnotationsWrapper = props => {
|
|
|
37
38
|
value: inlineCommentAnnotationsState
|
|
38
39
|
}, /*#__PURE__*/React.createElement(AnnotationRangeProvider, {
|
|
39
40
|
allowCommentsOnMedia: (_annotationProvider$i = annotationProvider === null || annotationProvider === void 0 ? void 0 : (_annotationProvider$i2 = annotationProvider.inlineComment) === null || _annotationProvider$i2 === void 0 ? void 0 : _annotationProvider$i2.allowCommentsOnMedia) !== null && _annotationProvider$i !== void 0 ? _annotationProvider$i : false
|
|
40
|
-
}, /*#__PURE__*/React.createElement(AnnotationsContextWrapper, {
|
|
41
|
+
}, /*#__PURE__*/React.createElement(AnnotationHoverContext, null, /*#__PURE__*/React.createElement(AnnotationsContextWrapper, {
|
|
41
42
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
42
43
|
rendererRef: rendererRef
|
|
43
44
|
}, /*#__PURE__*/React.createElement(LoadAnnotations, {
|
|
44
45
|
adfDocument: adfDocument
|
|
45
46
|
}), /*#__PURE__*/React.createElement(AnnotationView, {
|
|
46
47
|
createAnalyticsEvent: createAnalyticsEvent
|
|
47
|
-
}), children))));
|
|
48
|
+
}), children)))));
|
|
48
49
|
};
|
|
49
50
|
export { TextWithAnnotationDraft } from './draft';
|
|
50
51
|
export { MarkElement as AnnotationMark } from './element';
|
|
@@ -8,7 +8,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
8
8
|
import _extends from "@babel/runtime/helpers/extends";
|
|
9
9
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
10
10
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
11
|
-
var _excluded = ["marks", "mediaElement"];
|
|
11
|
+
var _excluded = ["marks", "mediaElement", "isDrafting"];
|
|
12
12
|
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; }
|
|
13
13
|
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) { _defineProperty(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; }
|
|
14
14
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -112,6 +112,8 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref5) {
|
|
|
112
112
|
var _marks$map;
|
|
113
113
|
var marks = _ref5.marks,
|
|
114
114
|
mediaElement = _ref5.mediaElement,
|
|
115
|
+
_ref5$isDrafting = _ref5.isDrafting,
|
|
116
|
+
isDrafting = _ref5$isDrafting === void 0 ? false : _ref5$isDrafting,
|
|
115
117
|
rest = _objectWithoutProperties(_ref5, _excluded);
|
|
116
118
|
var _useState = useState('default'),
|
|
117
119
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -151,7 +153,7 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref5) {
|
|
|
151
153
|
observer.disconnect();
|
|
152
154
|
};
|
|
153
155
|
}, [mediaElement, setStatus]);
|
|
154
|
-
if (!activeParentIds.length) {
|
|
156
|
+
if (!isDrafting && !activeParentIds.length) {
|
|
155
157
|
return null;
|
|
156
158
|
}
|
|
157
159
|
var onClick = function onClick(e) {
|
|
@@ -192,7 +194,9 @@ var Media = /*#__PURE__*/function (_PureComponent) {
|
|
|
192
194
|
ssr = _this$props.ssr,
|
|
193
195
|
width = _this$props.width,
|
|
194
196
|
height = _this$props.height,
|
|
195
|
-
mediaSingleElement = _this$props.mediaSingleElement
|
|
197
|
+
mediaSingleElement = _this$props.mediaSingleElement,
|
|
198
|
+
_this$props$isDraftin = _this$props.isDrafting,
|
|
199
|
+
isDrafting = _this$props$isDraftin === void 0 ? false : _this$props$isDraftin;
|
|
196
200
|
var annotationMarks = _this.props.isAnnotationMark ? _this.props.marks.filter(_this.props.isAnnotationMark) : undefined;
|
|
197
201
|
var borderMark = _this.props.marks.find(_this.props.isBorderMark);
|
|
198
202
|
var linkMark = _this.props.marks.find(_this.props.isLinkMark);
|
|
@@ -214,7 +218,8 @@ var Media = /*#__PURE__*/function (_PureComponent) {
|
|
|
214
218
|
marks: annotationMarks,
|
|
215
219
|
mediaElement: mediaSingleElement,
|
|
216
220
|
width: width,
|
|
217
|
-
height: height
|
|
221
|
+
height: height,
|
|
222
|
+
isDrafting: isDrafting
|
|
218
223
|
}), jsx(MediaCard, _extends({
|
|
219
224
|
contextIdentifierProvider: contextIdentifierProvider
|
|
220
225
|
}, _this.props, {
|
|
@@ -302,7 +307,8 @@ var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
|
302
307
|
}) : dataAttributes;
|
|
303
308
|
}, [applyDraftAnnotation, dataAttributes]);
|
|
304
309
|
return jsx(Media, _extends({}, props, {
|
|
305
|
-
dataAttributes: dataAttributesWithDraftAnnotation
|
|
310
|
+
dataAttributes: dataAttributesWithDraftAnnotation,
|
|
311
|
+
isDrafting: shouldApplyDraftAnnotation
|
|
306
312
|
}));
|
|
307
313
|
};
|
|
308
314
|
export default MediaWithDraftAnnotation;
|
|
@@ -10,6 +10,7 @@ import { akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth, akEditorWideL
|
|
|
10
10
|
import { FullPagePadding } from '../../../ui/Renderer/style';
|
|
11
11
|
import { uiMediaSingleBaseStyles, uiMediaSingleLayoutStyles } from './styles';
|
|
12
12
|
import { useAnnotationRangeDispatch } from '../../../ui/annotations/contexts/AnnotationRangeContext';
|
|
13
|
+
import { useAnnotationHoverDispatch } from '../../../ui/annotations/contexts/AnnotationHoverContext';
|
|
13
14
|
var DEFAULT_WIDTH = 250;
|
|
14
15
|
var DEFAULT_HEIGHT = 200;
|
|
15
16
|
var isMediaElement = function isMediaElement(media) {
|
|
@@ -103,8 +104,9 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
|
|
|
103
104
|
|
|
104
105
|
// TODO: put appearance-based padding into theme instead
|
|
105
106
|
|
|
106
|
-
var
|
|
107
|
+
var isFullPage = rendererAppearance === 'full-page';
|
|
107
108
|
var isFullWidth = rendererAppearance === 'full-width';
|
|
109
|
+
var padding = isFullPage ? FullPagePadding * 2 : 0;
|
|
108
110
|
var calcDimensions = useCallback(function (mediaContainerWidth) {
|
|
109
111
|
var containerWidth = getMediaContainerWidth(mediaContainerWidth, layout);
|
|
110
112
|
var maxWidth = containerWidth;
|
|
@@ -137,22 +139,34 @@ var MediaSingleWithChildren = function MediaSingleWithChildren(props) {
|
|
|
137
139
|
}, [height, width]);
|
|
138
140
|
var _useAnnotationRangeDi = useAnnotationRangeDispatch(),
|
|
139
141
|
setHoverTarget = _useAnnotationRangeDi.setHoverTarget;
|
|
142
|
+
var _useAnnotationHoverDi = useAnnotationHoverDispatch(),
|
|
143
|
+
cancelTimeout = _useAnnotationHoverDi.cancelTimeout,
|
|
144
|
+
initiateTimeout = _useAnnotationHoverDi.initiateTimeout,
|
|
145
|
+
setIsWithinRange = _useAnnotationHoverDi.setIsWithinRange;
|
|
146
|
+
var isFullPageRenderer = isFullPage || isFullWidth;
|
|
140
147
|
useEffect(function () {
|
|
141
148
|
var mediaSingleElement = ref.current;
|
|
142
|
-
var
|
|
149
|
+
var handleMouseEnter = function handleMouseEnter(event) {
|
|
150
|
+
cancelTimeout();
|
|
143
151
|
if (event.buttons === 0) {
|
|
144
152
|
setHoverTarget && setHoverTarget(event.target);
|
|
153
|
+
setIsWithinRange(true);
|
|
145
154
|
}
|
|
146
155
|
};
|
|
147
|
-
|
|
148
|
-
|
|
156
|
+
var handleMouseLeave = function handleMouseLeave() {
|
|
157
|
+
initiateTimeout();
|
|
158
|
+
};
|
|
159
|
+
if (mediaSingleElement && isFullPageRenderer) {
|
|
160
|
+
mediaSingleElement.addEventListener('mouseenter', handleMouseEnter);
|
|
161
|
+
mediaSingleElement.addEventListener('mouseleave', handleMouseLeave);
|
|
149
162
|
}
|
|
150
163
|
return function () {
|
|
151
|
-
if (mediaSingleElement) {
|
|
152
|
-
mediaSingleElement.removeEventListener('mouseenter',
|
|
164
|
+
if (mediaSingleElement && isFullPageRenderer) {
|
|
165
|
+
mediaSingleElement.removeEventListener('mouseenter', handleMouseEnter);
|
|
166
|
+
mediaSingleElement.removeEventListener('mouseleave', handleMouseLeave);
|
|
153
167
|
}
|
|
154
168
|
};
|
|
155
|
-
}, [setHoverTarget]);
|
|
169
|
+
}, [setHoverTarget, isFullPageRenderer, cancelTimeout, initiateTimeout, setIsWithinRange]);
|
|
156
170
|
|
|
157
171
|
// Note: in SSR mode the `window` object is not defined,
|
|
158
172
|
// therefore width here is 0, see:
|
|
@@ -46,7 +46,7 @@ import { EditorMediaClientProvider } from '../../react/utils/EditorMediaClientPr
|
|
|
46
46
|
export var NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
47
47
|
export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
48
48
|
var packageName = "@atlaskit/renderer";
|
|
49
|
-
var packageVersion = "109.
|
|
49
|
+
var packageVersion = "109.19.1";
|
|
50
50
|
export var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
51
51
|
_inherits(Renderer, _PureComponent);
|
|
52
52
|
var _super = _createSuper(Renderer);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { createContext, useState, useContext, useMemo, useRef, useCallback } from 'react';
|
|
3
|
+
var AnnotationHoverStateContext = /*#__PURE__*/createContext({
|
|
4
|
+
isWithinRange: false
|
|
5
|
+
});
|
|
6
|
+
var AnnotationHoverDispatchContext = /*#__PURE__*/createContext({
|
|
7
|
+
cancelTimeout: function cancelTimeout() {},
|
|
8
|
+
initiateTimeout: function initiateTimeout() {},
|
|
9
|
+
setIsWithinRange: function setIsWithinRange() {}
|
|
10
|
+
});
|
|
11
|
+
export var AnnotationHoverContext = function AnnotationHoverContext(_ref) {
|
|
12
|
+
var children = _ref.children;
|
|
13
|
+
var _useState = useState(false),
|
|
14
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15
|
+
isWithinRange = _useState2[0],
|
|
16
|
+
setIsWithinRange = _useState2[1];
|
|
17
|
+
var timeoutHandler = useRef();
|
|
18
|
+
var cancelTimeout = useCallback(function () {
|
|
19
|
+
if (timeoutHandler) {
|
|
20
|
+
clearTimeout(timeoutHandler.current);
|
|
21
|
+
}
|
|
22
|
+
}, [timeoutHandler]);
|
|
23
|
+
var initiateTimeout = useCallback(function () {
|
|
24
|
+
if (isWithinRange) {
|
|
25
|
+
timeoutHandler.current = setTimeout(function () {
|
|
26
|
+
setIsWithinRange(false);
|
|
27
|
+
}, 500);
|
|
28
|
+
}
|
|
29
|
+
}, [isWithinRange]);
|
|
30
|
+
var stateData = useMemo(function () {
|
|
31
|
+
return {
|
|
32
|
+
isWithinRange: isWithinRange
|
|
33
|
+
};
|
|
34
|
+
}, [isWithinRange]);
|
|
35
|
+
var dispatchData = useMemo(function () {
|
|
36
|
+
return {
|
|
37
|
+
cancelTimeout: cancelTimeout,
|
|
38
|
+
initiateTimeout: initiateTimeout,
|
|
39
|
+
setIsWithinRange: setIsWithinRange
|
|
40
|
+
};
|
|
41
|
+
}, [cancelTimeout, initiateTimeout, setIsWithinRange]);
|
|
42
|
+
return /*#__PURE__*/React.createElement(AnnotationHoverStateContext.Provider, {
|
|
43
|
+
value: stateData
|
|
44
|
+
}, /*#__PURE__*/React.createElement(AnnotationHoverDispatchContext.Provider, {
|
|
45
|
+
value: dispatchData
|
|
46
|
+
}, children));
|
|
47
|
+
};
|
|
48
|
+
export var useAnnotationHoverContext = function useAnnotationHoverContext() {
|
|
49
|
+
return useContext(AnnotationHoverStateContext);
|
|
50
|
+
};
|
|
51
|
+
export var useAnnotationHoverDispatch = function useAnnotationHoverDispatch() {
|
|
52
|
+
return useContext(AnnotationHoverDispatchContext);
|
|
53
|
+
};
|
|
@@ -8,6 +8,7 @@ import { RendererContext as ActionsContext } from '../../RendererActionsContext'
|
|
|
8
8
|
export var Mounter = /*#__PURE__*/React.memo(function (props) {
|
|
9
9
|
var Component = props.component,
|
|
10
10
|
range = props.range,
|
|
11
|
+
isWithinRange = props.isWithinRange,
|
|
11
12
|
isAnnotationAllowed = props.isAnnotationAllowed,
|
|
12
13
|
wrapperDOM = props.wrapperDOM,
|
|
13
14
|
onCloseProps = props.onClose,
|
|
@@ -113,6 +114,7 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
|
|
|
113
114
|
}, [onCloseProps, removeDraftModeCallback, createAnalyticsEvent]);
|
|
114
115
|
return /*#__PURE__*/React.createElement(Component, {
|
|
115
116
|
range: range,
|
|
117
|
+
isWithinRange: isWithinRange,
|
|
116
118
|
wrapperDOM: wrapperDOM.current,
|
|
117
119
|
isAnnotationAllowed: isAnnotationAllowed,
|
|
118
120
|
onClose: onCloseCallback,
|
|
@@ -2,6 +2,7 @@ import React, { useContext } from 'react';
|
|
|
2
2
|
import { Mounter } from './mounter';
|
|
3
3
|
import { RendererContext as ActionsContext } from '../../RendererActionsContext';
|
|
4
4
|
import { useAnnotationRangeDispatch, useAnnotationRangeState } from '../contexts/AnnotationRangeContext';
|
|
5
|
+
import { useAnnotationHoverContext } from '../contexts/AnnotationHoverContext';
|
|
5
6
|
export var RangeValidator = function RangeValidator(props) {
|
|
6
7
|
var component = props.component,
|
|
7
8
|
rendererRef = props.rendererRef,
|
|
@@ -14,11 +15,14 @@ export var RangeValidator = function RangeValidator(props) {
|
|
|
14
15
|
var _useAnnotationRangeSt = useAnnotationRangeState(),
|
|
15
16
|
range = _useAnnotationRangeSt.range,
|
|
16
17
|
type = _useAnnotationRangeSt.type;
|
|
18
|
+
var _useAnnotationHoverCo = useAnnotationHoverContext(),
|
|
19
|
+
isWithinRange = _useAnnotationHoverCo.isWithinRange;
|
|
17
20
|
if (!range || type !== 'hover') {
|
|
18
21
|
return null;
|
|
19
22
|
}
|
|
20
23
|
var documentPosition = actions.getPositionFromRange(range);
|
|
21
24
|
return /*#__PURE__*/React.createElement(Mounter, {
|
|
25
|
+
isWithinRange: isWithinRange,
|
|
22
26
|
range: range,
|
|
23
27
|
wrapperDOM: rendererRef,
|
|
24
28
|
component: component,
|
|
@@ -7,6 +7,7 @@ import { useLoadAnnotations } from './hooks/use-load-annotations';
|
|
|
7
7
|
import { useAnnotationStateByTypeEvent } from './hooks/use-events';
|
|
8
8
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
9
9
|
import { AnnotationRangeProvider } from './contexts/AnnotationRangeContext';
|
|
10
|
+
import { AnnotationHoverContext } from './contexts/AnnotationHoverContext';
|
|
10
11
|
var LoadAnnotations = /*#__PURE__*/React.memo(function (_ref) {
|
|
11
12
|
var adfDocument = _ref.adfDocument;
|
|
12
13
|
useLoadAnnotations({
|
|
@@ -33,14 +34,14 @@ export var AnnotationsWrapper = function AnnotationsWrapper(props) {
|
|
|
33
34
|
value: inlineCommentAnnotationsState
|
|
34
35
|
}, /*#__PURE__*/React.createElement(AnnotationRangeProvider, {
|
|
35
36
|
allowCommentsOnMedia: (_annotationProvider$i = annotationProvider === null || annotationProvider === void 0 || (_annotationProvider$i2 = annotationProvider.inlineComment) === null || _annotationProvider$i2 === void 0 ? void 0 : _annotationProvider$i2.allowCommentsOnMedia) !== null && _annotationProvider$i !== void 0 ? _annotationProvider$i : false
|
|
36
|
-
}, /*#__PURE__*/React.createElement(AnnotationsContextWrapper, {
|
|
37
|
+
}, /*#__PURE__*/React.createElement(AnnotationHoverContext, null, /*#__PURE__*/React.createElement(AnnotationsContextWrapper, {
|
|
37
38
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
38
39
|
rendererRef: rendererRef
|
|
39
40
|
}, /*#__PURE__*/React.createElement(LoadAnnotations, {
|
|
40
41
|
adfDocument: adfDocument
|
|
41
42
|
}), /*#__PURE__*/React.createElement(AnnotationView, {
|
|
42
43
|
createAnalyticsEvent: createAnalyticsEvent
|
|
43
|
-
}), children))));
|
|
44
|
+
}), children)))));
|
|
44
45
|
};
|
|
45
46
|
export { TextWithAnnotationDraft } from './draft';
|
|
46
47
|
export { MarkElement as AnnotationMark } from './element';
|
|
@@ -25,6 +25,7 @@ export type MediaProps = MediaCardProps & {
|
|
|
25
25
|
mediaSingleElement?: HTMLElement | null;
|
|
26
26
|
width?: number;
|
|
27
27
|
height?: number;
|
|
28
|
+
isDrafting: boolean;
|
|
28
29
|
};
|
|
29
30
|
declare const MediaWithDraftAnnotation: (props: PropsWithChildren<MediaProps>) => jsx.JSX.Element;
|
|
30
31
|
export default MediaWithDraftAnnotation;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface AnnotationHoverStateContext {
|
|
3
|
+
isWithinRange: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface AnnotationHoverDispatchContext {
|
|
6
|
+
cancelTimeout: () => void;
|
|
7
|
+
initiateTimeout: () => void;
|
|
8
|
+
setIsWithinRange: (isWithinRange: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const AnnotationHoverContext: ({ children, }: {
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}) => JSX.Element;
|
|
13
|
+
export declare const useAnnotationHoverContext: () => AnnotationHoverStateContext;
|
|
14
|
+
export declare const useAnnotationHoverDispatch: () => AnnotationHoverDispatchContext;
|
|
@@ -5,6 +5,7 @@ import type { Position } from '../types';
|
|
|
5
5
|
import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
6
6
|
type Props = {
|
|
7
7
|
range: Range;
|
|
8
|
+
isWithinRange: boolean;
|
|
8
9
|
component: React.ComponentType<InlineCommentHoverComponentProps>;
|
|
9
10
|
wrapperDOM: React.RefObject<HTMLDivElement>;
|
|
10
11
|
documentPosition: Position | false;
|
|
@@ -25,6 +25,7 @@ export type MediaProps = MediaCardProps & {
|
|
|
25
25
|
mediaSingleElement?: HTMLElement | null;
|
|
26
26
|
width?: number;
|
|
27
27
|
height?: number;
|
|
28
|
+
isDrafting: boolean;
|
|
28
29
|
};
|
|
29
30
|
declare const MediaWithDraftAnnotation: (props: PropsWithChildren<MediaProps>) => jsx.JSX.Element;
|
|
30
31
|
export default MediaWithDraftAnnotation;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface AnnotationHoverStateContext {
|
|
3
|
+
isWithinRange: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface AnnotationHoverDispatchContext {
|
|
6
|
+
cancelTimeout: () => void;
|
|
7
|
+
initiateTimeout: () => void;
|
|
8
|
+
setIsWithinRange: (isWithinRange: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const AnnotationHoverContext: ({ children, }: {
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}) => JSX.Element;
|
|
13
|
+
export declare const useAnnotationHoverContext: () => AnnotationHoverStateContext;
|
|
14
|
+
export declare const useAnnotationHoverDispatch: () => AnnotationHoverDispatchContext;
|
|
@@ -5,6 +5,7 @@ import type { Position } from '../types';
|
|
|
5
5
|
import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
6
6
|
type Props = {
|
|
7
7
|
range: Range;
|
|
8
|
+
isWithinRange: boolean;
|
|
8
9
|
component: React.ComponentType<InlineCommentHoverComponentProps>;
|
|
9
10
|
wrapperDOM: React.RefObject<HTMLDivElement>;
|
|
10
11
|
documentPosition: Position | false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "109.
|
|
3
|
+
"version": "109.19.1",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@atlaskit/analytics-next": "^9.2.0",
|
|
32
32
|
"@atlaskit/button": "^17.12.0",
|
|
33
33
|
"@atlaskit/code": "^15.1.0",
|
|
34
|
-
"@atlaskit/editor-common": "^78.
|
|
34
|
+
"@atlaskit/editor-common": "^78.29.0",
|
|
35
35
|
"@atlaskit/editor-json-transformer": "^8.10.0",
|
|
36
36
|
"@atlaskit/editor-palette": "1.5.3",
|
|
37
37
|
"@atlaskit/editor-prosemirror": "3.0.0",
|