@atlaskit/renderer 115.0.5 → 115.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/cjs/actions/index.js +14 -8
- package/dist/cjs/react/nodes/media/index.js +5 -1
- package/dist/cjs/react/nodes/tableNew.js +9 -3
- package/dist/cjs/ui/Renderer/index.js +4 -5
- package/dist/cjs/ui/annotations/context.js +14 -1
- package/dist/cjs/ui/annotations/contexts/AnnotationRangeContext.js +199 -35
- package/dist/cjs/ui/annotations/draft/component.js +6 -1
- package/dist/cjs/ui/annotations/element/useInlineAnnotationProps.js +5 -1
- package/dist/cjs/ui/annotations/hooks/user-selection.js +14 -9
- package/dist/cjs/ui/annotations/hover/mounter.js +31 -10
- package/dist/cjs/ui/annotations/hover/range-validator.js +2 -1
- package/dist/cjs/ui/annotations/index.js +2 -1
- package/dist/cjs/ui/annotations/selection/mounter.js +41 -12
- package/dist/cjs/ui/annotations/selection/range-validator.js +10 -7
- package/dist/cjs/ui/annotations/wrapper.js +48 -2
- package/dist/es2019/actions/index.js +12 -8
- package/dist/es2019/react/nodes/media/index.js +6 -1
- package/dist/es2019/react/nodes/tableNew.js +9 -3
- package/dist/es2019/ui/Renderer/index.js +4 -5
- package/dist/es2019/ui/annotations/context.js +14 -1
- package/dist/es2019/ui/annotations/contexts/AnnotationRangeContext.js +207 -30
- package/dist/es2019/ui/annotations/draft/component.js +7 -1
- package/dist/es2019/ui/annotations/element/useInlineAnnotationProps.js +6 -1
- package/dist/es2019/ui/annotations/hooks/user-selection.js +14 -9
- package/dist/es2019/ui/annotations/hover/mounter.js +33 -10
- package/dist/es2019/ui/annotations/hover/range-validator.js +2 -1
- package/dist/es2019/ui/annotations/index.js +2 -1
- package/dist/es2019/ui/annotations/selection/mounter.js +43 -12
- package/dist/es2019/ui/annotations/selection/range-validator.js +6 -4
- package/dist/es2019/ui/annotations/wrapper.js +49 -1
- package/dist/esm/actions/index.js +14 -8
- package/dist/esm/react/nodes/media/index.js +5 -1
- package/dist/esm/react/nodes/tableNew.js +9 -3
- package/dist/esm/ui/Renderer/index.js +4 -5
- package/dist/esm/ui/annotations/context.js +14 -1
- package/dist/esm/ui/annotations/contexts/AnnotationRangeContext.js +198 -34
- package/dist/esm/ui/annotations/draft/component.js +6 -1
- package/dist/esm/ui/annotations/element/useInlineAnnotationProps.js +5 -1
- package/dist/esm/ui/annotations/hooks/user-selection.js +14 -9
- package/dist/esm/ui/annotations/hover/mounter.js +31 -10
- package/dist/esm/ui/annotations/hover/range-validator.js +2 -1
- package/dist/esm/ui/annotations/index.js +2 -1
- package/dist/esm/ui/annotations/selection/mounter.js +41 -12
- package/dist/esm/ui/annotations/selection/range-validator.js +10 -7
- package/dist/esm/ui/annotations/wrapper.js +47 -1
- package/dist/types/actions/index.d.ts +5 -0
- package/dist/types/ui/annotations/context.d.ts +13 -1
- package/dist/types/ui/annotations/contexts/AnnotationRangeContext.d.ts +46 -4
- package/dist/types/ui/annotations/hooks/user-selection.d.ts +2 -1
- package/dist/types/ui/annotations/hover/mounter.d.ts +10 -2
- package/dist/types/ui/annotations/hover/range-validator.d.ts +14 -3
- package/dist/types/ui/annotations/selection/mounter.d.ts +10 -2
- package/dist/types/ui/annotations/selection/range-validator.d.ts +14 -3
- package/dist/types/ui/annotations/wrapper.d.ts +2 -0
- package/dist/types-ts4.5/actions/index.d.ts +5 -0
- package/dist/types-ts4.5/ui/annotations/context.d.ts +13 -1
- package/dist/types-ts4.5/ui/annotations/contexts/AnnotationRangeContext.d.ts +46 -4
- package/dist/types-ts4.5/ui/annotations/hooks/user-selection.d.ts +2 -0
- package/dist/types-ts4.5/ui/annotations/hover/mounter.d.ts +10 -2
- package/dist/types-ts4.5/ui/annotations/hover/range-validator.d.ts +14 -3
- package/dist/types-ts4.5/ui/annotations/selection/mounter.d.ts +10 -2
- package/dist/types-ts4.5/ui/annotations/selection/range-validator.d.ts +14 -3
- package/dist/types-ts4.5/ui/annotations/wrapper.d.ts +2 -0
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 115.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#152081](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/152081)
|
|
8
|
+
[`703ddc882eae5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/703ddc882eae5) -
|
|
9
|
+
The annotation draft position has been moved to a high-order context so it can persist across
|
|
10
|
+
unmounts. The Range context has also been update to support multiple active annotation drafts.
|
|
11
|
+
This is because currently both the media and selection comments can be opened
|
|
12
|
+
|
|
3
13
|
## 115.0.5
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -22,10 +22,6 @@ var _matchesUtils = require("./matches-utils");
|
|
|
22
22
|
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; }
|
|
23
23
|
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; }
|
|
24
24
|
var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
25
|
-
// Any kind of refence is allowed
|
|
26
|
-
// Ignored via go/ees005
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
-
|
|
29
25
|
function RendererActions() {
|
|
30
26
|
var initFromContext = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
31
27
|
(0, _classCallCheck2.default)(this, RendererActions);
|
|
@@ -33,6 +29,7 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
33
29
|
// This module can only be used when wrapped with
|
|
34
30
|
// the <RendererContext> component for now.
|
|
35
31
|
(0, _defineProperty2.default)(this, "initFromContext", false);
|
|
32
|
+
(0, _defineProperty2.default)(this, "debugAnalyticLoggingEnabled", false);
|
|
36
33
|
// TODO: EDITOR-595 - This method is temporary and should be removed once the following issue
|
|
37
34
|
// has been identified and fixed: https://atlassian.slack.com/archives/C08JK0WSCH5/p1745902609966999
|
|
38
35
|
// This is a copy of the original canApplyAnnotationOnRange. If that returns false this is run to figure out exactly why
|
|
@@ -115,7 +112,7 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
115
112
|
key: "_privateValidatePositionsForAnnotation",
|
|
116
113
|
value: function _privateValidatePositionsForAnnotation(from, to) {
|
|
117
114
|
if (!this.doc || !this.schema) {
|
|
118
|
-
if (this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
115
|
+
if (this.debugAnalyticLoggingEnabled && this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
119
116
|
this.onAnalyticsEvent({
|
|
120
117
|
// @ts-ignore
|
|
121
118
|
action: 'failed',
|
|
@@ -137,7 +134,7 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
137
134
|
}
|
|
138
135
|
var currentSelection = _state.TextSelection.create(this.doc, from, to);
|
|
139
136
|
if ((0, _utils.isEmptyTextSelection)(currentSelection, this.schema)) {
|
|
140
|
-
if (this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
137
|
+
if (this.debugAnalyticLoggingEnabled && this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
141
138
|
this.onAnalyticsEvent({
|
|
142
139
|
// @ts-ignore
|
|
143
140
|
action: 'failed',
|
|
@@ -161,7 +158,7 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
161
158
|
from: from,
|
|
162
159
|
to: to
|
|
163
160
|
}, this.doc, this.schema);
|
|
164
|
-
if (!result && this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
161
|
+
if (this.debugAnalyticLoggingEnabled && !result && this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
165
162
|
this.onAnalyticsEvent({
|
|
166
163
|
// @ts-ignore
|
|
167
164
|
action: 'failed',
|
|
@@ -341,7 +338,7 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
341
338
|
key: "isValidAnnotationPosition",
|
|
342
339
|
value: function isValidAnnotationPosition(pos) {
|
|
343
340
|
if (!pos || !this.doc) {
|
|
344
|
-
if (this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
341
|
+
if (this.debugAnalyticLoggingEnabled && this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
345
342
|
this.onAnalyticsEvent({
|
|
346
343
|
// @ts-ignore
|
|
347
344
|
action: 'failed',
|
|
@@ -548,5 +545,14 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
548
545
|
schema: this.schema
|
|
549
546
|
}, annotationId);
|
|
550
547
|
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* This is a temporary method used for controlling when extra analytics shoulw be logged.
|
|
551
|
+
*/
|
|
552
|
+
}, {
|
|
553
|
+
key: "_setDebugLogging",
|
|
554
|
+
value: function _setDebugLogging(enabled) {
|
|
555
|
+
this.debugAnalyticLoggingEnabled = enabled;
|
|
556
|
+
}
|
|
551
557
|
}]);
|
|
552
558
|
}();
|
|
@@ -35,6 +35,7 @@ var _reactIntlNext = require("react-intl-next");
|
|
|
35
35
|
var _useInlineCommentsFilter = require("../../../ui/annotations/hooks/use-inline-comments-filter");
|
|
36
36
|
var _useInlineCommentSubscriber = require("../../../ui/annotations/hooks/use-inline-comment-subscriber");
|
|
37
37
|
var _types = require("@atlaskit/editor-common/types");
|
|
38
|
+
var _AnnotationRangeContext = require("../../../ui/annotations/contexts/AnnotationRangeContext");
|
|
38
39
|
var _excluded = ["marks", "mediaSingleElement", "isDrafting"],
|
|
39
40
|
_excluded2 = ["marks", "mediaSingleElement", "isDrafting"];
|
|
40
41
|
/**
|
|
@@ -430,7 +431,10 @@ var Media = /*#__PURE__*/function (_PureComponent) {
|
|
|
430
431
|
}]);
|
|
431
432
|
}(_react.PureComponent);
|
|
432
433
|
var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
433
|
-
var
|
|
434
|
+
var draftPositionOld = _react.default.useContext(_context.AnnotationsDraftContext);
|
|
435
|
+
var _useAnnotationRangeSt = (0, _AnnotationRangeContext.useAnnotationRangeState)(),
|
|
436
|
+
hoverDraftDocumentPosition = _useAnnotationRangeSt.hoverDraftDocumentPosition;
|
|
437
|
+
var draftPosition = (0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix') ? hoverDraftDocumentPosition : draftPositionOld;
|
|
434
438
|
var dataAttributes = props.dataAttributes;
|
|
435
439
|
var pos = dataAttributes && dataAttributes['data-renderer-start-pos'];
|
|
436
440
|
var _useState9 = (0, _react.useState)(),
|
|
@@ -386,11 +386,17 @@ var TableContainer = exports.TableContainer = /*#__PURE__*/function (_React$Comp
|
|
|
386
386
|
this.updatedLayout = layout;
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
+
// defined in colgroup.tsx:
|
|
390
|
+
// appearance == comment && allowTableResizing && means it is a comment
|
|
391
|
+
// appearance == comment && !allowTableResizing && means it is a inline comment
|
|
392
|
+
// for inline comments, the table should inherit the width of the parent component rather than maintain its own size
|
|
393
|
+
var isInsideInlineComment = rendererAppearance === 'comment' && !allowTableResizing;
|
|
394
|
+
|
|
389
395
|
// These styling removes extra padding for `comment` rendererAppearance.
|
|
390
396
|
// This is especially relevant for Jira which only uses `comment` appearance and does not need padding.
|
|
391
397
|
var resizerContainerPadding = rendererAppearance === 'comment' ? 0 : gutterPadding;
|
|
392
|
-
var resizerItemMaxWidth = rendererAppearance === 'comment' ? "min(100cqw, var(--ak-editor-table-max-width))" : "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))";
|
|
393
|
-
var resizerItemWidth = rendererAppearance === 'comment' ? "min(100cqw, ".concat(tableWidthAttribute, ")") : "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ".concat(tableWidthAttribute, ")");
|
|
398
|
+
var resizerItemMaxWidth = rendererAppearance === 'comment' ? isInsideInlineComment ? 'inherit' : "min(100cqw, var(--ak-editor-table-max-width))" : "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), var(--ak-editor-table-max-width))";
|
|
399
|
+
var resizerItemWidth = rendererAppearance === 'comment' ? isInsideInlineComment ? 'inherit' : "min(100cqw, ".concat(tableWidthAttribute, ")") : "min(calc(100cqw - var(--ak-editor-table-gutter-padding)), ".concat(tableWidthAttribute, ")");
|
|
394
400
|
|
|
395
401
|
// full width tables can have either left-aligned or centered layout despite looking centered in the renderer.
|
|
396
402
|
// in these cases, keep the alignment unset
|
|
@@ -412,7 +418,7 @@ var TableContainer = exports.TableContainer = /*#__PURE__*/function (_React$Comp
|
|
|
412
418
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
413
419
|
,
|
|
414
420
|
style: {
|
|
415
|
-
width: "min(calc(100cqw - ".concat(resizerContainerPadding, "px), ").concat(tableWidthAttribute, ")")
|
|
421
|
+
width: isInsideInlineComment ? '100%' : "min(calc(100cqw - ".concat(resizerContainerPadding, "px), ").concat(tableWidthAttribute, ")")
|
|
416
422
|
}
|
|
417
423
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
418
424
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
@@ -60,11 +60,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
60
60
|
var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
61
61
|
var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
62
62
|
var packageName = "@atlaskit/renderer";
|
|
63
|
-
var packageVersion = "115.0.
|
|
63
|
+
var packageVersion = "115.0.6";
|
|
64
64
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
65
65
|
containerName: 'ak-renderer-wrapper',
|
|
66
|
-
containerType: 'inline-size'
|
|
67
|
-
contain: 'layout style inline-size'
|
|
66
|
+
containerType: 'inline-size'
|
|
68
67
|
});
|
|
69
68
|
var handleMouseTripleClickInTables = function handleMouseTripleClickInTables(event) {
|
|
70
69
|
var _parentElement, _parentElement2;
|
|
@@ -603,10 +602,10 @@ var RendererWrapper = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
603
602
|
// Only apply container-type = inline-size when having a known width in full-page/full-width/comment mode.
|
|
604
603
|
// Otherwise when appearance is unspecified the renderer size is decided by the content.
|
|
605
604
|
// In this case we can't set the container-type = inline-size as it will collapse width to 0.
|
|
606
|
-
return
|
|
605
|
+
return appearance === 'comment' &&
|
|
607
606
|
// In case of having excerpt-include on page there are multiple renderers nested.
|
|
608
607
|
// Make sure only the root renderer is set to be query container.
|
|
609
|
-
isTopLevelRenderer && (0, _platformFeatureFlags.fg)('platform-
|
|
608
|
+
isTopLevelRenderer && (0, _platformFeatureFlags.fg)('platform-ssr-table-resize') ? (0, _react2.jsx)("div", {
|
|
610
609
|
css: setAsQueryContainerStyles
|
|
611
610
|
}, renderer) : renderer;
|
|
612
611
|
});
|
|
@@ -18,10 +18,23 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
18
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
19
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
20
20
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
21
|
-
var AnnotationsDraftContext = exports.AnnotationsDraftContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
22
21
|
var ProvidersContext = exports.ProvidersContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
23
22
|
var InlineCommentsStateContext = exports.InlineCommentsStateContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
24
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
* @deprecated The FG platform_renderer_annotation_draft_position_fix will make this context redundant as the draft position
|
|
27
|
+
* has been moved to the AnnotationRangeProvider in order to be more consistent with the hover and selection ranges.
|
|
28
|
+
* Once the FG is rolled out this context will be removed. Please ensure any changes are duplicated to the AnnotationRangeProvider.
|
|
29
|
+
*/
|
|
30
|
+
var AnnotationsDraftContext = exports.AnnotationsDraftContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @private
|
|
34
|
+
* @deprecated The FG platform_renderer_annotation_draft_position_fix will make this context redundant as the draft position
|
|
35
|
+
* has been moved to the AnnotationRangeProvider in order to be more consistent with the hover and selection ranges.
|
|
36
|
+
* Once the FG is rolled out this context will be removed. Please ensure any changes are duplicated to the AnnotationRangeProvider.
|
|
37
|
+
*/
|
|
25
38
|
// Ignored via go/ees005
|
|
26
39
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
27
40
|
var AnnotationsDraftContextWrapper = exports.AnnotationsDraftContextWrapper = /*#__PURE__*/function (_React$Component) {
|
|
@@ -5,25 +5,30 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.useAnnotationRangeState = exports.useAnnotationRangeDispatch = exports.AnnotationRangeProvider = void 0;
|
|
8
|
+
exports.useAnnotationRangeState = exports.useAnnotationRangeDispatch = exports.AnnotationRangeProviderInner = exports.AnnotationRangeProvider = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
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 && {}.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
|
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; }
|
|
15
16
|
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; }
|
|
16
|
-
|
|
17
|
+
var initialState = {
|
|
18
|
+
range: null,
|
|
19
|
+
draftRange: null,
|
|
20
|
+
type: null,
|
|
21
|
+
selectionRange: null,
|
|
22
|
+
hoverRange: null,
|
|
23
|
+
selectionDraftRange: null,
|
|
24
|
+
hoverDraftRange: null,
|
|
25
|
+
selectionDraftDocumentPosition: null,
|
|
26
|
+
hoverDraftDocumentPosition: null
|
|
27
|
+
};
|
|
28
|
+
function reducerOld(state, action) {
|
|
17
29
|
switch (action.type) {
|
|
18
30
|
case 'clear':
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
range: null,
|
|
22
|
-
draftRange: null,
|
|
23
|
-
type: null
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
return state;
|
|
31
|
+
return initialState;
|
|
27
32
|
case 'clearSelection':
|
|
28
33
|
if (state.type === 'selection') {
|
|
29
34
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -48,11 +53,11 @@ function reducer(state, action) {
|
|
|
48
53
|
return state;
|
|
49
54
|
case 'clearHover':
|
|
50
55
|
if (state.type === 'hover') {
|
|
51
|
-
return {
|
|
56
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
52
57
|
range: null,
|
|
53
58
|
draftRange: null,
|
|
54
59
|
type: null
|
|
55
|
-
};
|
|
60
|
+
});
|
|
56
61
|
}
|
|
57
62
|
return state;
|
|
58
63
|
case 'setSelection':
|
|
@@ -73,11 +78,11 @@ function reducer(state, action) {
|
|
|
73
78
|
return state;
|
|
74
79
|
case 'setDraftSelection':
|
|
75
80
|
if (state.draftRange !== action.draftRange || state.type !== 'selection') {
|
|
76
|
-
return {
|
|
81
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
77
82
|
range: null,
|
|
78
83
|
draftRange: action.draftRange,
|
|
79
84
|
type: null
|
|
80
|
-
};
|
|
85
|
+
});
|
|
81
86
|
}
|
|
82
87
|
return state;
|
|
83
88
|
case 'setDraftHover':
|
|
@@ -88,33 +93,128 @@ function reducer(state, action) {
|
|
|
88
93
|
}
|
|
89
94
|
return state;
|
|
90
95
|
}
|
|
96
|
+
return state;
|
|
97
|
+
}
|
|
98
|
+
function reducerNew(state, action) {
|
|
99
|
+
switch (action.type) {
|
|
100
|
+
case 'clear':
|
|
101
|
+
return initialState;
|
|
102
|
+
case 'clearSelection':
|
|
103
|
+
if (state.selectionRange !== null) {
|
|
104
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
105
|
+
selectionRange: null,
|
|
106
|
+
type: state.type === 'selection' ? null : state.type
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return state;
|
|
110
|
+
case 'clearHover':
|
|
111
|
+
{
|
|
112
|
+
if (state.hoverRange !== null) {
|
|
113
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
114
|
+
hoverRange: null,
|
|
115
|
+
type: state.type === 'hover' ? null : state.type
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return state;
|
|
119
|
+
}
|
|
120
|
+
case 'setSelection':
|
|
121
|
+
if (state.selectionRange !== action.range) {
|
|
122
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
123
|
+
selectionRange: action.range,
|
|
124
|
+
type: 'selection'
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return state;
|
|
128
|
+
case 'setHover':
|
|
129
|
+
if (state.hoverRange !== action.range) {
|
|
130
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
131
|
+
hoverRange: action.range,
|
|
132
|
+
type: 'hover'
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return state;
|
|
136
|
+
case 'promoteSelectionToDraft':
|
|
137
|
+
// we should only promote the range to a draft if the current range type is a selection
|
|
138
|
+
// we should also store the promotion type, so that a clear will not accidently clear the draft of a
|
|
139
|
+
// different type
|
|
140
|
+
if (state.selectionDraftRange !== state.selectionRange) {
|
|
141
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
142
|
+
selectionRange: null,
|
|
143
|
+
type: state.type === 'selection' ? null : state.type,
|
|
144
|
+
selectionDraftRange: state.selectionRange,
|
|
145
|
+
selectionDraftDocumentPosition: action.position
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return state;
|
|
149
|
+
case 'promoteHoverToDraft':
|
|
150
|
+
if (state.hoverDraftRange !== state.hoverRange) {
|
|
151
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
152
|
+
hoverRange: null,
|
|
153
|
+
type: state.type === 'hover' ? null : state.type,
|
|
154
|
+
hoverDraftRange: state.hoverRange,
|
|
155
|
+
hoverDraftDocumentPosition: action.position
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return state;
|
|
159
|
+
case 'clearSelectionDraft':
|
|
160
|
+
if (state.selectionDraftRange !== null) {
|
|
161
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
162
|
+
selectionDraftRange: null,
|
|
163
|
+
selectionDraftDocumentPosition: null
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return state;
|
|
167
|
+
case 'clearHoverDraft':
|
|
168
|
+
if (state.hoverDraftRange !== null) {
|
|
169
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
170
|
+
hoverDraftRange: null,
|
|
171
|
+
hoverDraftDocumentPosition: null
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return state;
|
|
175
|
+
}
|
|
176
|
+
return state;
|
|
91
177
|
}
|
|
92
178
|
var AnnotationRangeStateContext = /*#__PURE__*/(0, _react.createContext)({
|
|
93
179
|
range: null,
|
|
94
|
-
|
|
95
|
-
|
|
180
|
+
type: null,
|
|
181
|
+
selectionDraftRange: null,
|
|
182
|
+
hoverDraftRange: null,
|
|
183
|
+
selectionDraftDocumentPosition: null,
|
|
184
|
+
hoverDraftDocumentPosition: null
|
|
96
185
|
});
|
|
97
186
|
var AnnotationRangeDispatchContext = /*#__PURE__*/(0, _react.createContext)({
|
|
98
187
|
clearRange: function clearRange() {},
|
|
99
188
|
clearSelectionRange: function clearSelectionRange() {},
|
|
100
|
-
clearDraftRange: function clearDraftRange() {},
|
|
101
189
|
clearHoverRange: function clearHoverRange() {},
|
|
102
|
-
|
|
103
|
-
|
|
190
|
+
setSelectionRange: function setSelectionRange() {},
|
|
191
|
+
// if platform_renderer_annotation_draft_position_fix is off; then
|
|
192
|
+
setDraftRange: function setDraftRange() {},
|
|
193
|
+
clearDraftRange: function clearDraftRange() {},
|
|
194
|
+
// end-if
|
|
195
|
+
|
|
196
|
+
// if platform_renderer_annotation_draft_position_fix is on; then
|
|
197
|
+
promoteSelectionToDraft: function promoteSelectionToDraft() {},
|
|
198
|
+
promoteHoverToDraft: function promoteHoverToDraft() {},
|
|
199
|
+
clearSelectionDraft: function clearSelectionDraft() {},
|
|
200
|
+
clearHoverDraft: function clearHoverDraft() {}
|
|
201
|
+
// end-if
|
|
104
202
|
});
|
|
105
|
-
var
|
|
203
|
+
var AnnotationRangeProviderInner = exports.AnnotationRangeProviderInner = function AnnotationRangeProviderInner(_ref) {
|
|
106
204
|
var children = _ref.children,
|
|
107
205
|
allowCommentsOnMedia = _ref.allowCommentsOnMedia;
|
|
108
|
-
var _useReducer = (0, _react.useReducer)(
|
|
109
|
-
range: null,
|
|
110
|
-
draftRange: null,
|
|
111
|
-
type: null
|
|
112
|
-
}),
|
|
206
|
+
var _useReducer = (0, _react.useReducer)((0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix') ? reducerNew : reducerOld, initialState),
|
|
113
207
|
_useReducer2 = (0, _slicedToArray2.default)(_useReducer, 2),
|
|
114
208
|
_useReducer2$ = _useReducer2[0],
|
|
115
209
|
range = _useReducer2$.range,
|
|
116
210
|
draftRange = _useReducer2$.draftRange,
|
|
211
|
+
selectionRange = _useReducer2$.selectionRange,
|
|
212
|
+
hoverRange = _useReducer2$.hoverRange,
|
|
117
213
|
type = _useReducer2$.type,
|
|
214
|
+
selectionDraftRange = _useReducer2$.selectionDraftRange,
|
|
215
|
+
selectionDraftDocumentPosition = _useReducer2$.selectionDraftDocumentPosition,
|
|
216
|
+
hoverDraftRange = _useReducer2$.hoverDraftRange,
|
|
217
|
+
hoverDraftDocumentPosition = _useReducer2$.hoverDraftDocumentPosition,
|
|
118
218
|
dispatch = _useReducer2[1];
|
|
119
219
|
var clearRange = (0, _react.useCallback)(function () {
|
|
120
220
|
return dispatch({
|
|
@@ -142,7 +242,7 @@ var AnnotationRangeProvider = exports.AnnotationRangeProvider = function Annotat
|
|
|
142
242
|
type: 'clearHover'
|
|
143
243
|
});
|
|
144
244
|
}, []);
|
|
145
|
-
var
|
|
245
|
+
var setSelectionRange = (0, _react.useCallback)(function (range) {
|
|
146
246
|
return dispatch({
|
|
147
247
|
type: 'setSelection',
|
|
148
248
|
range: range
|
|
@@ -175,30 +275,94 @@ var AnnotationRangeProvider = exports.AnnotationRangeProvider = function Annotat
|
|
|
175
275
|
range: range
|
|
176
276
|
});
|
|
177
277
|
}, []);
|
|
278
|
+
var promoteSelectionToDraft = (0, _react.useCallback)(function (position) {
|
|
279
|
+
dispatch({
|
|
280
|
+
type: 'promoteSelectionToDraft',
|
|
281
|
+
position: position
|
|
282
|
+
});
|
|
283
|
+
}, []);
|
|
284
|
+
var clearSelectionDraft = (0, _react.useCallback)(function () {
|
|
285
|
+
dispatch({
|
|
286
|
+
type: 'clearSelectionDraft'
|
|
287
|
+
});
|
|
288
|
+
}, []);
|
|
289
|
+
var promoteHoverToDraft = (0, _react.useCallback)(function (position) {
|
|
290
|
+
dispatch({
|
|
291
|
+
type: 'promoteHoverToDraft',
|
|
292
|
+
position: position
|
|
293
|
+
});
|
|
294
|
+
}, []);
|
|
295
|
+
var clearHoverDraft = (0, _react.useCallback)(function () {
|
|
296
|
+
dispatch({
|
|
297
|
+
type: 'clearHoverDraft'
|
|
298
|
+
});
|
|
299
|
+
}, []);
|
|
178
300
|
var stateData = (0, _react.useMemo)(function () {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
301
|
+
if ((0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix')) {
|
|
302
|
+
return {
|
|
303
|
+
// We techinically have two ranges, however we only want to expose one of them at a time, because only one draft
|
|
304
|
+
// can be active at a time. The type of range is used to determine which range is active.
|
|
305
|
+
range: type === 'selection' ? selectionRange : hoverRange,
|
|
306
|
+
type: type,
|
|
307
|
+
selectionDraftRange: selectionDraftRange,
|
|
308
|
+
hoverDraftRange: hoverDraftRange,
|
|
309
|
+
selectionDraftDocumentPosition: selectionDraftDocumentPosition,
|
|
310
|
+
hoverDraftDocumentPosition: hoverDraftDocumentPosition
|
|
311
|
+
};
|
|
312
|
+
} else {
|
|
313
|
+
return {
|
|
314
|
+
range: range,
|
|
315
|
+
draftRange: draftRange,
|
|
316
|
+
type: type,
|
|
317
|
+
// I've updated some refs to use the new selectionDraftRange, this is being add here to be fowards compatible
|
|
318
|
+
// with the new changes coming in platform_renderer_annotation_draft_position_fix.
|
|
319
|
+
selectionDraftRange: draftRange,
|
|
320
|
+
hoverDraftRange: draftRange,
|
|
321
|
+
selectionDraftDocumentPosition: null,
|
|
322
|
+
hoverDraftDocumentPosition: null
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
}, [range, draftRange, selectionRange, hoverRange, type, selectionDraftRange, selectionDraftDocumentPosition, hoverDraftRange, hoverDraftDocumentPosition]);
|
|
185
326
|
var dispatchData = (0, _react.useMemo)(function () {
|
|
186
327
|
return {
|
|
187
328
|
clearRange: clearRange,
|
|
188
329
|
clearSelectionRange: clearSelectionRange,
|
|
189
330
|
clearDraftRange: clearDraftRange,
|
|
190
331
|
clearHoverRange: clearHoverRange,
|
|
191
|
-
|
|
332
|
+
setSelectionRange: setSelectionRange,
|
|
192
333
|
setDraftRange: setDraftRange,
|
|
193
|
-
setHoverTarget: !!allowCommentsOnMedia ? setHoverTarget : undefined
|
|
334
|
+
setHoverTarget: !!allowCommentsOnMedia ? setHoverTarget : undefined,
|
|
335
|
+
promoteSelectionToDraft: promoteSelectionToDraft,
|
|
336
|
+
promoteHoverToDraft: promoteHoverToDraft,
|
|
337
|
+
clearSelectionDraft: clearSelectionDraft,
|
|
338
|
+
clearHoverDraft: clearHoverDraft
|
|
194
339
|
};
|
|
195
|
-
}, [allowCommentsOnMedia, clearRange, clearSelectionRange, clearDraftRange, clearHoverRange,
|
|
340
|
+
}, [allowCommentsOnMedia, clearRange, clearSelectionRange, clearDraftRange, clearHoverRange, setSelectionRange, setDraftRange, setHoverTarget, promoteSelectionToDraft, promoteHoverToDraft, clearSelectionDraft, clearHoverDraft]);
|
|
196
341
|
return /*#__PURE__*/_react.default.createElement(AnnotationRangeStateContext.Provider, {
|
|
197
342
|
value: stateData
|
|
198
343
|
}, /*#__PURE__*/_react.default.createElement(AnnotationRangeDispatchContext.Provider, {
|
|
199
344
|
value: dispatchData
|
|
200
345
|
}, children));
|
|
201
346
|
};
|
|
347
|
+
var AnnotationRangeProvider = exports.AnnotationRangeProvider = function AnnotationRangeProvider(_ref2) {
|
|
348
|
+
var children = _ref2.children,
|
|
349
|
+
allowCommentsOnMedia = _ref2.allowCommentsOnMedia,
|
|
350
|
+
isNestedRender = _ref2.isNestedRender;
|
|
351
|
+
if ((0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix')) {
|
|
352
|
+
/*
|
|
353
|
+
* If this is a nested render, we do not provide the context
|
|
354
|
+
* because it has already been provided higher up the component tree
|
|
355
|
+
* and we need the original context to create annotations on extensions.
|
|
356
|
+
*/
|
|
357
|
+
return isNestedRender ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children) : /*#__PURE__*/_react.default.createElement(AnnotationRangeProviderInner, {
|
|
358
|
+
allowCommentsOnMedia: allowCommentsOnMedia
|
|
359
|
+
}, children);
|
|
360
|
+
} else {
|
|
361
|
+
return /*#__PURE__*/_react.default.createElement(AnnotationRangeProviderInner, {
|
|
362
|
+
allowCommentsOnMedia: allowCommentsOnMedia
|
|
363
|
+
}, children);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
202
366
|
var useAnnotationRangeState = exports.useAnnotationRangeState = function useAnnotationRangeState() {
|
|
203
367
|
return (0, _react.useContext)(AnnotationRangeStateContext);
|
|
204
368
|
};
|
|
@@ -9,6 +9,7 @@ exports.getAnnotationIndex = exports.applyAnnotationOnText = exports.TextWithAnn
|
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
13
|
var _types = require("../types");
|
|
13
14
|
var _context = require("../context");
|
|
14
15
|
var _text = require("./text");
|
|
@@ -17,6 +18,7 @@ var _dom = require("./dom");
|
|
|
17
18
|
var _segmentText = require("../../../react/utils/segment-text");
|
|
18
19
|
var _renderTextSegments = require("../../../react/utils/render-text-segments");
|
|
19
20
|
var _AnnotationManagerContext = require("../contexts/AnnotationManagerContext");
|
|
21
|
+
var _AnnotationRangeContext = require("../contexts/AnnotationRangeContext");
|
|
20
22
|
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); }
|
|
21
23
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
24
|
/**
|
|
@@ -120,7 +122,10 @@ var TextWithAnnotationDraft = exports.TextWithAnnotationDraft = function TextWit
|
|
|
120
122
|
end: endPos
|
|
121
123
|
};
|
|
122
124
|
}, [endPos, startPos]);
|
|
123
|
-
var
|
|
125
|
+
var nextDraftPositionOld = _react.default.useContext(_context.AnnotationsDraftContext);
|
|
126
|
+
var _useAnnotationRangeSt = (0, _AnnotationRangeContext.useAnnotationRangeState)(),
|
|
127
|
+
selectionDraftDocumentPosition = _useAnnotationRangeSt.selectionDraftDocumentPosition;
|
|
128
|
+
var nextDraftPosition = (0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix') ? selectionDraftDocumentPosition : nextDraftPositionOld;
|
|
124
129
|
var shouldApplyAnnotationAt = _react.default.useMemo(function () {
|
|
125
130
|
if (!nextDraftPosition) {
|
|
126
131
|
return false;
|
|
@@ -7,8 +7,12 @@ exports.useInlineAnnotationProps = useInlineAnnotationProps;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
9
|
var _context = require("../context");
|
|
10
|
+
var _AnnotationRangeContext = require("../contexts/AnnotationRangeContext");
|
|
10
11
|
function useInlineAnnotationProps(props) {
|
|
11
|
-
var
|
|
12
|
+
var draftPositionOld = (0, _react.useContext)(_context.AnnotationsDraftContext);
|
|
13
|
+
var _useAnnotationRangeSt = (0, _AnnotationRangeContext.useAnnotationRangeState)(),
|
|
14
|
+
selectionDraftDocumentPosition = _useAnnotationRangeSt.selectionDraftDocumentPosition;
|
|
15
|
+
var draftPosition = (0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix') ? selectionDraftDocumentPosition : draftPositionOld;
|
|
12
16
|
if (!(0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes')) {
|
|
13
17
|
return {};
|
|
14
18
|
}
|
|
@@ -14,11 +14,12 @@ var useUserSelectionRange = exports.useUserSelectionRange = function useUserSele
|
|
|
14
14
|
var selectionTimeoutRef = (0, _react.useRef)();
|
|
15
15
|
var _useAnnotationRangeDi = (0, _AnnotationRangeContext.useAnnotationRangeDispatch)(),
|
|
16
16
|
clearRange = _useAnnotationRangeDi.clearRange,
|
|
17
|
-
|
|
17
|
+
clearSelectionRange = _useAnnotationRangeDi.clearSelectionRange,
|
|
18
|
+
setSelectionRange = _useAnnotationRangeDi.setSelectionRange;
|
|
18
19
|
var _useAnnotationRangeSt = (0, _AnnotationRangeContext.useAnnotationRangeState)(),
|
|
19
20
|
range = _useAnnotationRangeSt.range,
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
type = _useAnnotationRangeSt.type,
|
|
22
|
+
selectionDraftRange = _useAnnotationRangeSt.selectionDraftRange;
|
|
22
23
|
var lastRangeRef = (0, _react.useRef)(null);
|
|
23
24
|
var onSelectionChange = (0, _react.useCallback)(function (event) {
|
|
24
25
|
if ((0, _platformFeatureFlags.fg)('platform_renderer_triple_click_selects_paragraph')) {
|
|
@@ -55,7 +56,7 @@ var useUserSelectionRange = exports.useUserSelectionRange = function useUserSele
|
|
|
55
56
|
_range = sel.getRangeAt(0);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
+
setSelectionRange(_range.cloneRange());
|
|
59
60
|
lastRangeRef.current = _range;
|
|
60
61
|
}
|
|
61
62
|
}, 100);
|
|
@@ -96,11 +97,11 @@ var useUserSelectionRange = exports.useUserSelectionRange = function useUserSele
|
|
|
96
97
|
var lastChild = parentNode !== null && parentNode !== void 0 && parentNode.lastChild && (parentNode === null || parentNode === void 0 || (_parentNode$lastChild = parentNode.lastChild) === null || _parentNode$lastChild === void 0 ? void 0 : _parentNode$lastChild.nodeType) === Node.TEXT_NODE ? parentNode === null || parentNode === void 0 ? void 0 : parentNode.lastChild : parentNode === null || parentNode === void 0 || (_parentNode$lastChild2 = parentNode.lastChild) === null || _parentNode$lastChild2 === void 0 ? void 0 : _parentNode$lastChild2.childNodes[0];
|
|
97
98
|
_range.setEnd(lastChild, lastChild.length || 0);
|
|
98
99
|
}
|
|
99
|
-
|
|
100
|
+
setSelectionRange(_range.cloneRange());
|
|
100
101
|
}
|
|
101
102
|
}, 250);
|
|
102
103
|
}
|
|
103
|
-
}, [rendererDOM,
|
|
104
|
+
}, [rendererDOM, setSelectionRange]);
|
|
104
105
|
(0, _react.useEffect)(function () {
|
|
105
106
|
if (!document || !rendererDOM) {
|
|
106
107
|
return;
|
|
@@ -112,8 +113,12 @@ var useUserSelectionRange = exports.useUserSelectionRange = function useUserSele
|
|
|
112
113
|
// Ignored via go/ees005
|
|
113
114
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
114
115
|
document.removeEventListener('selectionchange', onSelectionChange);
|
|
115
|
-
|
|
116
|
+
if ((0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix')) {
|
|
117
|
+
clearSelectionRange();
|
|
118
|
+
} else {
|
|
119
|
+
clearRange();
|
|
120
|
+
}
|
|
116
121
|
};
|
|
117
|
-
}, [rendererDOM, onSelectionChange, clearRange]);
|
|
118
|
-
return [type
|
|
122
|
+
}, [rendererDOM, onSelectionChange, clearSelectionRange, clearRange]);
|
|
123
|
+
return [type, range, selectionDraftRange, (0, _platformFeatureFlags.fg)('platform_renderer_annotation_draft_position_fix') ? clearSelectionRange : clearRange];
|
|
119
124
|
};
|