@atlaskit/renderer 109.20.3 → 109.21.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 +10 -0
- package/dist/cjs/actions/index.js +8 -5
- package/dist/cjs/react/index.js +1 -1
- package/dist/cjs/react/nodes/media/index.js +7 -3
- package/dist/cjs/steps/index.js +28 -8
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/cjs/ui/annotations/hover/mounter.js +5 -2
- package/dist/cjs/ui/annotations/hover/range-validator.js +5 -1
- package/dist/cjs/ui/annotations/selection/mounter.js +5 -2
- package/dist/cjs/ui/annotations/selection/range-validator.js +4 -1
- package/dist/es2019/actions/index.js +8 -5
- package/dist/es2019/react/index.js +1 -1
- package/dist/es2019/react/nodes/media/index.js +9 -5
- package/dist/es2019/steps/index.js +30 -8
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/es2019/ui/annotations/hover/mounter.js +5 -2
- package/dist/es2019/ui/annotations/hover/range-validator.js +5 -1
- package/dist/es2019/ui/annotations/selection/mounter.js +5 -2
- package/dist/es2019/ui/annotations/selection/range-validator.js +4 -1
- package/dist/esm/actions/index.js +8 -5
- package/dist/esm/react/index.js +1 -1
- package/dist/esm/react/nodes/media/index.js +9 -5
- package/dist/esm/steps/index.js +28 -8
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/esm/ui/annotations/hover/mounter.js +5 -2
- package/dist/esm/ui/annotations/hover/range-validator.js +5 -1
- package/dist/esm/ui/annotations/selection/mounter.js +5 -2
- package/dist/esm/ui/annotations/selection/range-validator.js +4 -1
- package/dist/types/actions/index.d.ts +3 -3
- package/dist/types/steps/index.d.ts +1 -1
- package/dist/types-ts4.5/actions/index.d.ts +3 -3
- package/dist/types-ts4.5/steps/index.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 109.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#93519](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/93519) [`587934fc0174`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/587934fc0174) - Allow real time comments to correctly infer position of comment on media
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 109.20.3
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -169,11 +169,11 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
169
169
|
}
|
|
170
170
|
}, {
|
|
171
171
|
key: "getPositionFromRange",
|
|
172
|
-
value: function getPositionFromRange(range) {
|
|
172
|
+
value: function getPositionFromRange(range, isCommentsOnMediaBugFixEnabled) {
|
|
173
173
|
if (!this.doc || !this.schema || !range) {
|
|
174
174
|
return false;
|
|
175
175
|
}
|
|
176
|
-
return (0, _steps.getPosFromRange)(range);
|
|
176
|
+
return (0, _steps.getPosFromRange)(range, isCommentsOnMediaBugFixEnabled);
|
|
177
177
|
}
|
|
178
178
|
}, {
|
|
179
179
|
key: "getAnnotationMarks",
|
|
@@ -218,7 +218,7 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
218
218
|
}
|
|
219
219
|
}, {
|
|
220
220
|
key: "applyAnnotation",
|
|
221
|
-
value: function applyAnnotation(pos, annotation) {
|
|
221
|
+
value: function applyAnnotation(pos, annotation, isCommentsOnMediaBugFixEnabled) {
|
|
222
222
|
if (!this.doc || !pos || !this.schema) {
|
|
223
223
|
return false;
|
|
224
224
|
}
|
|
@@ -227,10 +227,13 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
227
227
|
var annotationId = annotation.annotationId,
|
|
228
228
|
annotationType = annotation.annotationType;
|
|
229
229
|
var step;
|
|
230
|
-
|
|
230
|
+
var beforeNodePos = isCommentsOnMediaBugFixEnabled ?
|
|
231
|
+
// As part of fix for RAP, `from` points to the position right before media node
|
|
232
|
+
// hence, -1 is not needed
|
|
233
|
+
from :
|
|
231
234
|
// If from points to a node position,
|
|
232
235
|
// we need to 1 position before it for nodeAt to return the node itself
|
|
233
|
-
|
|
236
|
+
Math.max(from - 1, 0);
|
|
234
237
|
var possibleNode = this.doc.nodeAt(beforeNodePos);
|
|
235
238
|
if ((possibleNode === null || possibleNode === void 0 ? void 0 : possibleNode.type.name) === 'media') {
|
|
236
239
|
step = new _transform.AddNodeMarkStep(beforeNodePos, this.schema.marks.annotation.create({
|
package/dist/cjs/react/index.js
CHANGED
|
@@ -381,7 +381,7 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
|
|
|
381
381
|
var childHasLink = node.firstChild && node.firstChild.marks.filter(function (m) {
|
|
382
382
|
return isLinkMark(m) || _this5.allowMediaLinking === true;
|
|
383
383
|
}).length;
|
|
384
|
-
return _objectSpread(_objectSpread({}, this.getProps(node)), {}, {
|
|
384
|
+
return _objectSpread(_objectSpread({}, this.getProps(node, path)), {}, {
|
|
385
385
|
isInsideOfBlockNode: isInsideOfBlockNode,
|
|
386
386
|
childHasLink: childHasLink,
|
|
387
387
|
allowCaptions: this.media && this.media.allowCaptions,
|
|
@@ -293,6 +293,8 @@ var Media = /*#__PURE__*/function (_PureComponent) {
|
|
|
293
293
|
}(_react.PureComponent);
|
|
294
294
|
var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
295
295
|
var draftPosition = _react.default.useContext(_context.AnnotationsDraftContext);
|
|
296
|
+
var providers = (0, _react.useContext)(_context.ProvidersContext);
|
|
297
|
+
var isCommentsOnMediaBugFixEnabled = !!(providers !== null && providers !== void 0 && providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
296
298
|
var dataAttributes = props.dataAttributes;
|
|
297
299
|
var pos = dataAttributes && dataAttributes['data-renderer-start-pos'];
|
|
298
300
|
var _useState5 = (0, _react.useState)(),
|
|
@@ -304,17 +306,19 @@ var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
|
304
306
|
shouldApplyDraftAnnotation = _useState8[0],
|
|
305
307
|
setShouldApplyDraftAnnotation = _useState8[1];
|
|
306
308
|
(0, _react.useEffect)(function () {
|
|
309
|
+
var _draftPosition$from;
|
|
307
310
|
if (pos === undefined) {
|
|
308
311
|
return;
|
|
309
312
|
}
|
|
310
|
-
|
|
313
|
+
var posToCheck = isCommentsOnMediaBugFixEnabled ? ((_draftPosition$from = draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from) !== null && _draftPosition$from !== void 0 ? _draftPosition$from : 0) + 1 : draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from;
|
|
314
|
+
if (draftPosition !== null && posToCheck === pos) {
|
|
311
315
|
setShouldApplyDraftAnnotation(true);
|
|
312
|
-
setPosition(
|
|
316
|
+
setPosition(posToCheck);
|
|
313
317
|
} else if (draftPosition === null && shouldApplyDraftAnnotation) {
|
|
314
318
|
setShouldApplyDraftAnnotation(false);
|
|
315
319
|
setPosition(undefined);
|
|
316
320
|
}
|
|
317
|
-
}, [draftPosition, pos, shouldApplyDraftAnnotation]);
|
|
321
|
+
}, [draftPosition, pos, shouldApplyDraftAnnotation, isCommentsOnMediaBugFixEnabled]);
|
|
318
322
|
var applyDraftAnnotation = props.allowAnnotationsDraftMode && shouldApplyDraftAnnotation && position !== undefined;
|
|
319
323
|
var dataAttributesWithDraftAnnotation = (0, _react.useMemo)(function () {
|
|
320
324
|
return applyDraftAnnotation ? _objectSpread(_objectSpread({}, dataAttributes), {}, {
|
package/dist/cjs/steps/index.js
CHANGED
|
@@ -27,6 +27,16 @@ function findParent(element) {
|
|
|
27
27
|
}
|
|
28
28
|
return findParent(parentElement);
|
|
29
29
|
}
|
|
30
|
+
function findMediaParent(element) {
|
|
31
|
+
var parentElement = element.parentElement;
|
|
32
|
+
if (!parentElement || isRoot(parentElement)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if (parentElement.dataset.nodeType === 'mediaSingle') {
|
|
36
|
+
return parentElement;
|
|
37
|
+
}
|
|
38
|
+
return findMediaParent(parentElement);
|
|
39
|
+
}
|
|
30
40
|
function findParentBeforePointer(element) {
|
|
31
41
|
var parentElement = element.parentElement;
|
|
32
42
|
if (isRoot(parentElement) || !parentElement) {
|
|
@@ -163,18 +173,28 @@ function resolvePos(node, offset) {
|
|
|
163
173
|
}
|
|
164
174
|
return resolvedPos + offset;
|
|
165
175
|
}
|
|
166
|
-
function getPosFromRange(range) {
|
|
176
|
+
function getPosFromRange(range, isCommentsOnMediaBugFixEnabled) {
|
|
167
177
|
var startContainer = range.startContainer,
|
|
168
178
|
startOffset = range.startOffset,
|
|
169
179
|
endContainer = range.endContainer,
|
|
170
180
|
endOffset = range.endOffset;
|
|
171
|
-
var
|
|
172
|
-
if (
|
|
173
|
-
var pos
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
181
|
+
var possibleMediaElement = findParent(startContainer);
|
|
182
|
+
if (possibleMediaElement && getNodeType(possibleMediaElement) === 'media') {
|
|
183
|
+
var pos;
|
|
184
|
+
if (isCommentsOnMediaBugFixEnabled) {
|
|
185
|
+
var mediaSingleElement = findMediaParent(possibleMediaElement);
|
|
186
|
+
if (mediaSingleElement) {
|
|
187
|
+
pos = getStartPos(mediaSingleElement);
|
|
188
|
+
}
|
|
189
|
+
} else {
|
|
190
|
+
pos = getStartPos(possibleMediaElement);
|
|
191
|
+
}
|
|
192
|
+
if (pos !== undefined) {
|
|
193
|
+
return {
|
|
194
|
+
from: pos,
|
|
195
|
+
to: pos
|
|
196
|
+
};
|
|
197
|
+
}
|
|
178
198
|
}
|
|
179
199
|
var from = resolvePos(startContainer, startOffset);
|
|
180
200
|
var to = resolvePos(endContainer, endOffset);
|
|
@@ -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.21.0";
|
|
59
59
|
var Renderer = exports.Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
60
60
|
(0, _inherits2.default)(Renderer, _PureComponent);
|
|
61
61
|
var _super = _createSuper(Renderer);
|
|
@@ -13,6 +13,7 @@ var _draft = require("../draft");
|
|
|
13
13
|
var _analyticsListeners = require("@atlaskit/analytics-listeners");
|
|
14
14
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
15
15
|
var _RendererActionsContext = require("../../RendererActionsContext");
|
|
16
|
+
var _context = require("../context");
|
|
16
17
|
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); }
|
|
17
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 && 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; }
|
|
18
19
|
var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props) {
|
|
@@ -33,6 +34,8 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
|
|
|
33
34
|
draftDocumentPosition = _useState2[0],
|
|
34
35
|
setDraftDocumentPosition = _useState2[1];
|
|
35
36
|
var actions = (0, _react.useContext)(_RendererActionsContext.RendererContext);
|
|
37
|
+
var providers = (0, _react.useContext)(_context.ProvidersContext);
|
|
38
|
+
var isCommentsOnMediaBugFixEnabled = Boolean(providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
36
39
|
var onCreateCallback = (0, _react.useCallback)(function (annotationId) {
|
|
37
40
|
if (!isAnnotationAllowed || !documentPosition || !applyAnnotation) {
|
|
38
41
|
return false;
|
|
@@ -50,8 +53,8 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
|
|
|
50
53
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
51
54
|
}).fire(_analyticsListeners.FabricChannel.editor);
|
|
52
55
|
}
|
|
53
|
-
return applyAnnotation(draftDocumentPosition || documentPosition, annotation);
|
|
54
|
-
}, [isAnnotationAllowed, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent]);
|
|
56
|
+
return applyAnnotation(draftDocumentPosition || documentPosition, annotation, isCommentsOnMediaBugFixEnabled);
|
|
57
|
+
}, [isAnnotationAllowed, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent, isCommentsOnMediaBugFixEnabled]);
|
|
55
58
|
var createIndexCallback = (0, _react.useCallback)(function () {
|
|
56
59
|
if (!documentPosition || !generateIndexMatch) {
|
|
57
60
|
return false;
|
|
@@ -10,9 +10,11 @@ var _mounter = require("./mounter");
|
|
|
10
10
|
var _RendererActionsContext = require("../../RendererActionsContext");
|
|
11
11
|
var _AnnotationRangeContext = require("../contexts/AnnotationRangeContext");
|
|
12
12
|
var _AnnotationHoverContext = require("../contexts/AnnotationHoverContext");
|
|
13
|
+
var _context = require("../context");
|
|
13
14
|
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); }
|
|
14
15
|
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; }
|
|
15
16
|
var RangeValidator = exports.RangeValidator = function RangeValidator(props) {
|
|
17
|
+
var _providers$inlineComm;
|
|
16
18
|
var component = props.component,
|
|
17
19
|
rendererRef = props.rendererRef,
|
|
18
20
|
applyAnnotationDraftAt = props.applyAnnotationDraftAt,
|
|
@@ -26,10 +28,12 @@ var RangeValidator = exports.RangeValidator = function RangeValidator(props) {
|
|
|
26
28
|
type = _useAnnotationRangeSt.type;
|
|
27
29
|
var _useAnnotationHoverCo = (0, _AnnotationHoverContext.useAnnotationHoverContext)(),
|
|
28
30
|
isWithinRange = _useAnnotationHoverCo.isWithinRange;
|
|
31
|
+
var providers = (0, _react.useContext)(_context.ProvidersContext);
|
|
32
|
+
var isCommentsOnMediaBugFixEnabled = (_providers$inlineComm = providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugFixEnabled) !== null && _providers$inlineComm !== void 0 ? _providers$inlineComm : false;
|
|
29
33
|
if (!range || type !== 'hover') {
|
|
30
34
|
return null;
|
|
31
35
|
}
|
|
32
|
-
var documentPosition = actions.getPositionFromRange(range);
|
|
36
|
+
var documentPosition = actions.getPositionFromRange(range, isCommentsOnMediaBugFixEnabled);
|
|
33
37
|
return /*#__PURE__*/_react.default.createElement(_mounter.Mounter, {
|
|
34
38
|
isWithinRange: isWithinRange,
|
|
35
39
|
range: range,
|
|
@@ -13,6 +13,7 @@ var _draft = require("../draft");
|
|
|
13
13
|
var _analyticsListeners = require("@atlaskit/analytics-listeners");
|
|
14
14
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
15
15
|
var _RendererActionsContext = require("../../RendererActionsContext");
|
|
16
|
+
var _context = require("../context");
|
|
16
17
|
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); }
|
|
17
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 && 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; }
|
|
18
19
|
var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#__PURE__*/_react.default.memo(function (props) {
|
|
@@ -33,6 +34,8 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
33
34
|
draftDocumentPosition = _useState2[0],
|
|
34
35
|
setDraftDocumentPosition = _useState2[1];
|
|
35
36
|
var actions = (0, _react.useContext)(_RendererActionsContext.RendererContext);
|
|
37
|
+
var providers = (0, _react.useContext)(_context.ProvidersContext);
|
|
38
|
+
var isCommentsOnMediaBugFixEnabled = !!(providers !== null && providers !== void 0 && providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
36
39
|
var onCreateCallback = (0, _react.useCallback)(function (annotationId) {
|
|
37
40
|
// We want to support creation on a documentPosition if the user is only using ranges
|
|
38
41
|
// but we want to prioritize draft positions if they are being used by consumers
|
|
@@ -59,8 +62,8 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
59
62
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
60
63
|
}).fire(_analyticsListeners.FabricChannel.editor);
|
|
61
64
|
}
|
|
62
|
-
return applyAnnotation(positionToAnnotate, annotation);
|
|
63
|
-
}, [actions, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent]);
|
|
65
|
+
return applyAnnotation(positionToAnnotate, annotation, isCommentsOnMediaBugFixEnabled);
|
|
66
|
+
}, [actions, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent, isCommentsOnMediaBugFixEnabled]);
|
|
64
67
|
var createIndexCallback = (0, _react.useCallback)(function () {
|
|
65
68
|
if (!documentPosition || !generateIndexMatch) {
|
|
66
69
|
return false;
|
|
@@ -11,6 +11,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
var _userSelection = require("../hooks/user-selection");
|
|
12
12
|
var _mounter = require("./mounter");
|
|
13
13
|
var _RendererActionsContext = require("../../RendererActionsContext");
|
|
14
|
+
var _context = require("../context");
|
|
14
15
|
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); }
|
|
15
16
|
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; }
|
|
16
17
|
var SelectionRangeValidator = exports.SelectionRangeValidator = function SelectionRangeValidator(props) {
|
|
@@ -27,10 +28,12 @@ var SelectionRangeValidator = exports.SelectionRangeValidator = function Selecti
|
|
|
27
28
|
range = _useUserSelectionRang2[0],
|
|
28
29
|
draftRange = _useUserSelectionRang2[1],
|
|
29
30
|
clearRange = _useUserSelectionRang2[2];
|
|
31
|
+
var providers = (0, _react.useContext)(_context.ProvidersContext);
|
|
32
|
+
var isCommentsOnMediaBugFixEnabled = Boolean(providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
30
33
|
if (!range && !draftRange) {
|
|
31
34
|
return null;
|
|
32
35
|
}
|
|
33
|
-
var documentPosition = actions.getPositionFromRange(range);
|
|
36
|
+
var documentPosition = actions.getPositionFromRange(range, isCommentsOnMediaBugFixEnabled);
|
|
34
37
|
|
|
35
38
|
// This property is drilled down to consumers when a new range is selected to test it's validity
|
|
36
39
|
var isAnnotationAllowedOnRange = false;
|
|
@@ -145,11 +145,11 @@ export default class RendererActions {
|
|
|
145
145
|
}
|
|
146
146
|
return this._privateValidatePositionsForAnnotation(pos.from, pos.to);
|
|
147
147
|
}
|
|
148
|
-
getPositionFromRange(range) {
|
|
148
|
+
getPositionFromRange(range, isCommentsOnMediaBugFixEnabled) {
|
|
149
149
|
if (!this.doc || !this.schema || !range) {
|
|
150
150
|
return false;
|
|
151
151
|
}
|
|
152
|
-
return getPosFromRange(range);
|
|
152
|
+
return getPosFromRange(range, isCommentsOnMediaBugFixEnabled);
|
|
153
153
|
}
|
|
154
154
|
getAnnotationMarks() {
|
|
155
155
|
const {
|
|
@@ -192,7 +192,7 @@ export default class RendererActions {
|
|
|
192
192
|
}
|
|
193
193
|
return getAnnotationIdsFromRange(pos, this.doc, this.schema);
|
|
194
194
|
}
|
|
195
|
-
applyAnnotation(pos, annotation) {
|
|
195
|
+
applyAnnotation(pos, annotation, isCommentsOnMediaBugFixEnabled) {
|
|
196
196
|
if (!this.doc || !pos || !this.schema) {
|
|
197
197
|
return false;
|
|
198
198
|
}
|
|
@@ -205,10 +205,13 @@ export default class RendererActions {
|
|
|
205
205
|
annotationType
|
|
206
206
|
} = annotation;
|
|
207
207
|
let step;
|
|
208
|
-
|
|
208
|
+
const beforeNodePos = isCommentsOnMediaBugFixEnabled ?
|
|
209
|
+
// As part of fix for RAP, `from` points to the position right before media node
|
|
210
|
+
// hence, -1 is not needed
|
|
211
|
+
from :
|
|
209
212
|
// If from points to a node position,
|
|
210
213
|
// we need to 1 position before it for nodeAt to return the node itself
|
|
211
|
-
|
|
214
|
+
Math.max(from - 1, 0);
|
|
212
215
|
const possibleNode = this.doc.nodeAt(beforeNodePos);
|
|
213
216
|
if ((possibleNode === null || possibleNode === void 0 ? void 0 : possibleNode.type.name) === 'media') {
|
|
214
217
|
step = new AddNodeMarkStep(beforeNodePos, this.schema.marks.annotation.create({
|
|
@@ -337,7 +337,7 @@ export default class ReactSerializer {
|
|
|
337
337
|
const isLinkMark = mark => mark.type === link;
|
|
338
338
|
const childHasLink = node.firstChild && node.firstChild.marks.filter(m => isLinkMark(m) || this.allowMediaLinking === true).length;
|
|
339
339
|
return {
|
|
340
|
-
...this.getProps(node),
|
|
340
|
+
...this.getProps(node, path),
|
|
341
341
|
isInsideOfBlockNode,
|
|
342
342
|
childHasLink,
|
|
343
343
|
allowCaptions: this.media && this.media.allowCaptions,
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
|
|
5
|
-
import React, { PureComponent, Fragment, useEffect, useState, useMemo } from 'react';
|
|
5
|
+
import React, { PureComponent, Fragment, useEffect, useState, useMemo, useContext } from 'react';
|
|
6
6
|
import { jsx, css } from '@emotion/react';
|
|
7
7
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
8
8
|
import { MEDIA_CONTEXT } from '@atlaskit/analytics-namespaced-context';
|
|
@@ -15,7 +15,7 @@ import { getEventHandler } from '../../../utils';
|
|
|
15
15
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
16
16
|
import { MODE, PLATFORM } from '../../../analytics/events';
|
|
17
17
|
import AnnotationComponent from '../../marks/annotation';
|
|
18
|
-
import { AnnotationsDraftContext } from '../../../ui/annotations/context';
|
|
18
|
+
import { AnnotationsDraftContext, ProvidersContext } from '../../../ui/annotations/context';
|
|
19
19
|
import { CommentBadge as CommentBadgeComponent } from '@atlaskit/editor-common/media-single';
|
|
20
20
|
import { injectIntl } from 'react-intl-next';
|
|
21
21
|
import { useInlineCommentSubscriberContext, useInlineCommentsFilter } from '../../../ui/annotations/hooks';
|
|
@@ -271,6 +271,8 @@ class Media extends PureComponent {
|
|
|
271
271
|
}
|
|
272
272
|
const MediaWithDraftAnnotation = props => {
|
|
273
273
|
const draftPosition = React.useContext(AnnotationsDraftContext);
|
|
274
|
+
const providers = useContext(ProvidersContext);
|
|
275
|
+
const isCommentsOnMediaBugFixEnabled = !!(providers !== null && providers !== void 0 && providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
274
276
|
const {
|
|
275
277
|
dataAttributes
|
|
276
278
|
} = props;
|
|
@@ -278,17 +280,19 @@ const MediaWithDraftAnnotation = props => {
|
|
|
278
280
|
const [position, setPosition] = useState();
|
|
279
281
|
const [shouldApplyDraftAnnotation, setShouldApplyDraftAnnotation] = useState(false);
|
|
280
282
|
useEffect(() => {
|
|
283
|
+
var _draftPosition$from;
|
|
281
284
|
if (pos === undefined) {
|
|
282
285
|
return;
|
|
283
286
|
}
|
|
284
|
-
|
|
287
|
+
const posToCheck = isCommentsOnMediaBugFixEnabled ? ((_draftPosition$from = draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from) !== null && _draftPosition$from !== void 0 ? _draftPosition$from : 0) + 1 : draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from;
|
|
288
|
+
if (draftPosition !== null && posToCheck === pos) {
|
|
285
289
|
setShouldApplyDraftAnnotation(true);
|
|
286
|
-
setPosition(
|
|
290
|
+
setPosition(posToCheck);
|
|
287
291
|
} else if (draftPosition === null && shouldApplyDraftAnnotation) {
|
|
288
292
|
setShouldApplyDraftAnnotation(false);
|
|
289
293
|
setPosition(undefined);
|
|
290
294
|
}
|
|
291
|
-
}, [draftPosition, pos, shouldApplyDraftAnnotation]);
|
|
295
|
+
}, [draftPosition, pos, shouldApplyDraftAnnotation, isCommentsOnMediaBugFixEnabled]);
|
|
292
296
|
const applyDraftAnnotation = props.allowAnnotationsDraftMode && shouldApplyDraftAnnotation && position !== undefined;
|
|
293
297
|
const dataAttributesWithDraftAnnotation = useMemo(() => applyDraftAnnotation ? {
|
|
294
298
|
...dataAttributes,
|
|
@@ -19,6 +19,18 @@ function findParent(element) {
|
|
|
19
19
|
}
|
|
20
20
|
return findParent(parentElement);
|
|
21
21
|
}
|
|
22
|
+
function findMediaParent(element) {
|
|
23
|
+
const {
|
|
24
|
+
parentElement
|
|
25
|
+
} = element;
|
|
26
|
+
if (!parentElement || isRoot(parentElement)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (parentElement.dataset.nodeType === 'mediaSingle') {
|
|
30
|
+
return parentElement;
|
|
31
|
+
}
|
|
32
|
+
return findMediaParent(parentElement);
|
|
33
|
+
}
|
|
22
34
|
function findParentBeforePointer(element) {
|
|
23
35
|
const {
|
|
24
36
|
parentElement
|
|
@@ -157,20 +169,30 @@ export function resolvePos(node, offset) {
|
|
|
157
169
|
}
|
|
158
170
|
return resolvedPos + offset;
|
|
159
171
|
}
|
|
160
|
-
export function getPosFromRange(range) {
|
|
172
|
+
export function getPosFromRange(range, isCommentsOnMediaBugFixEnabled) {
|
|
161
173
|
const {
|
|
162
174
|
startContainer,
|
|
163
175
|
startOffset,
|
|
164
176
|
endContainer,
|
|
165
177
|
endOffset
|
|
166
178
|
} = range;
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
179
|
+
const possibleMediaElement = findParent(startContainer);
|
|
180
|
+
if (possibleMediaElement && getNodeType(possibleMediaElement) === 'media') {
|
|
181
|
+
let pos;
|
|
182
|
+
if (isCommentsOnMediaBugFixEnabled) {
|
|
183
|
+
const mediaSingleElement = findMediaParent(possibleMediaElement);
|
|
184
|
+
if (mediaSingleElement) {
|
|
185
|
+
pos = getStartPos(mediaSingleElement);
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
pos = getStartPos(possibleMediaElement);
|
|
189
|
+
}
|
|
190
|
+
if (pos !== undefined) {
|
|
191
|
+
return {
|
|
192
|
+
from: pos,
|
|
193
|
+
to: pos
|
|
194
|
+
};
|
|
195
|
+
}
|
|
174
196
|
}
|
|
175
197
|
const from = resolvePos(startContainer, startOffset);
|
|
176
198
|
const to = resolvePos(endContainer, endOffset);
|
|
@@ -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.21.0";
|
|
40
40
|
export class Renderer extends PureComponent {
|
|
41
41
|
constructor(props) {
|
|
42
42
|
super(props);
|
|
@@ -4,6 +4,7 @@ import { updateWindowSelectionAroundDraft } from '../draft';
|
|
|
4
4
|
import { FabricChannel } from '@atlaskit/analytics-listeners';
|
|
5
5
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { RendererContext as ActionsContext } from '../../RendererActionsContext';
|
|
7
|
+
import { ProvidersContext } from '../context';
|
|
7
8
|
export const Mounter = /*#__PURE__*/React.memo(props => {
|
|
8
9
|
const {
|
|
9
10
|
component: Component,
|
|
@@ -21,6 +22,8 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
|
|
|
21
22
|
} = props;
|
|
22
23
|
const [draftDocumentPosition, setDraftDocumentPosition] = useState();
|
|
23
24
|
const actions = useContext(ActionsContext);
|
|
25
|
+
const providers = useContext(ProvidersContext);
|
|
26
|
+
const isCommentsOnMediaBugFixEnabled = Boolean(providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
24
27
|
const onCreateCallback = useCallback(annotationId => {
|
|
25
28
|
if (!isAnnotationAllowed || !documentPosition || !applyAnnotation) {
|
|
26
29
|
return false;
|
|
@@ -38,8 +41,8 @@ export const Mounter = /*#__PURE__*/React.memo(props => {
|
|
|
38
41
|
eventType: EVENT_TYPE.TRACK
|
|
39
42
|
}).fire(FabricChannel.editor);
|
|
40
43
|
}
|
|
41
|
-
return applyAnnotation(draftDocumentPosition || documentPosition, annotation);
|
|
42
|
-
}, [isAnnotationAllowed, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent]);
|
|
44
|
+
return applyAnnotation(draftDocumentPosition || documentPosition, annotation, isCommentsOnMediaBugFixEnabled);
|
|
45
|
+
}, [isAnnotationAllowed, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent, isCommentsOnMediaBugFixEnabled]);
|
|
43
46
|
const createIndexCallback = useCallback(() => {
|
|
44
47
|
if (!documentPosition || !generateIndexMatch) {
|
|
45
48
|
return false;
|
|
@@ -3,7 +3,9 @@ import { Mounter } from './mounter';
|
|
|
3
3
|
import { RendererContext as ActionsContext } from '../../RendererActionsContext';
|
|
4
4
|
import { useAnnotationRangeDispatch, useAnnotationRangeState } from '../contexts/AnnotationRangeContext';
|
|
5
5
|
import { useAnnotationHoverContext } from '../contexts/AnnotationHoverContext';
|
|
6
|
+
import { ProvidersContext } from '../context';
|
|
6
7
|
export const RangeValidator = props => {
|
|
8
|
+
var _providers$inlineComm;
|
|
7
9
|
const {
|
|
8
10
|
component,
|
|
9
11
|
rendererRef,
|
|
@@ -22,10 +24,12 @@ export const RangeValidator = props => {
|
|
|
22
24
|
const {
|
|
23
25
|
isWithinRange
|
|
24
26
|
} = useAnnotationHoverContext();
|
|
27
|
+
const providers = useContext(ProvidersContext);
|
|
28
|
+
const isCommentsOnMediaBugFixEnabled = (_providers$inlineComm = providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugFixEnabled) !== null && _providers$inlineComm !== void 0 ? _providers$inlineComm : false;
|
|
25
29
|
if (!range || type !== 'hover') {
|
|
26
30
|
return null;
|
|
27
31
|
}
|
|
28
|
-
const documentPosition = actions.getPositionFromRange(range);
|
|
32
|
+
const documentPosition = actions.getPositionFromRange(range, isCommentsOnMediaBugFixEnabled);
|
|
29
33
|
return /*#__PURE__*/React.createElement(Mounter, {
|
|
30
34
|
isWithinRange: isWithinRange,
|
|
31
35
|
range: range,
|
|
@@ -4,6 +4,7 @@ import { updateWindowSelectionAroundDraft } from '../draft';
|
|
|
4
4
|
import { FabricChannel } from '@atlaskit/analytics-listeners';
|
|
5
5
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { RendererContext as ActionsContext } from '../../RendererActionsContext';
|
|
7
|
+
import { ProvidersContext } from '../context';
|
|
7
8
|
export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
|
|
8
9
|
const {
|
|
9
10
|
component: Component,
|
|
@@ -21,6 +22,8 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
|
|
|
21
22
|
} = props;
|
|
22
23
|
const [draftDocumentPosition, setDraftDocumentPosition] = useState();
|
|
23
24
|
const actions = useContext(ActionsContext);
|
|
25
|
+
const providers = useContext(ProvidersContext);
|
|
26
|
+
const isCommentsOnMediaBugFixEnabled = !!(providers !== null && providers !== void 0 && providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
24
27
|
const onCreateCallback = useCallback(annotationId => {
|
|
25
28
|
// We want to support creation on a documentPosition if the user is only using ranges
|
|
26
29
|
// but we want to prioritize draft positions if they are being used by consumers
|
|
@@ -47,8 +50,8 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
|
|
|
47
50
|
eventType: EVENT_TYPE.TRACK
|
|
48
51
|
}).fire(FabricChannel.editor);
|
|
49
52
|
}
|
|
50
|
-
return applyAnnotation(positionToAnnotate, annotation);
|
|
51
|
-
}, [actions, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent]);
|
|
53
|
+
return applyAnnotation(positionToAnnotate, annotation, isCommentsOnMediaBugFixEnabled);
|
|
54
|
+
}, [actions, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent, isCommentsOnMediaBugFixEnabled]);
|
|
52
55
|
const createIndexCallback = useCallback(() => {
|
|
53
56
|
if (!documentPosition || !generateIndexMatch) {
|
|
54
57
|
return false;
|
|
@@ -2,6 +2,7 @@ import React, { useContext } from 'react';
|
|
|
2
2
|
import { useUserSelectionRange } from '../hooks/user-selection';
|
|
3
3
|
import { SelectionInlineCommentMounter } from './mounter';
|
|
4
4
|
import { RendererContext as ActionsContext } from '../../RendererActionsContext';
|
|
5
|
+
import { ProvidersContext } from '../context';
|
|
5
6
|
export const SelectionRangeValidator = props => {
|
|
6
7
|
const {
|
|
7
8
|
selectionComponent,
|
|
@@ -14,10 +15,12 @@ export const SelectionRangeValidator = props => {
|
|
|
14
15
|
const [range, draftRange, clearRange] = useUserSelectionRange({
|
|
15
16
|
rendererRef
|
|
16
17
|
});
|
|
18
|
+
const providers = useContext(ProvidersContext);
|
|
19
|
+
const isCommentsOnMediaBugFixEnabled = Boolean(providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
17
20
|
if (!range && !draftRange) {
|
|
18
21
|
return null;
|
|
19
22
|
}
|
|
20
|
-
const documentPosition = actions.getPositionFromRange(range);
|
|
23
|
+
const documentPosition = actions.getPositionFromRange(range, isCommentsOnMediaBugFixEnabled);
|
|
21
24
|
|
|
22
25
|
// This property is drilled down to consumers when a new range is selected to test it's validity
|
|
23
26
|
let isAnnotationAllowedOnRange = false;
|
|
@@ -162,11 +162,11 @@ var RendererActions = /*#__PURE__*/function () {
|
|
|
162
162
|
}
|
|
163
163
|
}, {
|
|
164
164
|
key: "getPositionFromRange",
|
|
165
|
-
value: function getPositionFromRange(range) {
|
|
165
|
+
value: function getPositionFromRange(range, isCommentsOnMediaBugFixEnabled) {
|
|
166
166
|
if (!this.doc || !this.schema || !range) {
|
|
167
167
|
return false;
|
|
168
168
|
}
|
|
169
|
-
return getPosFromRange(range);
|
|
169
|
+
return getPosFromRange(range, isCommentsOnMediaBugFixEnabled);
|
|
170
170
|
}
|
|
171
171
|
}, {
|
|
172
172
|
key: "getAnnotationMarks",
|
|
@@ -211,7 +211,7 @@ var RendererActions = /*#__PURE__*/function () {
|
|
|
211
211
|
}
|
|
212
212
|
}, {
|
|
213
213
|
key: "applyAnnotation",
|
|
214
|
-
value: function applyAnnotation(pos, annotation) {
|
|
214
|
+
value: function applyAnnotation(pos, annotation, isCommentsOnMediaBugFixEnabled) {
|
|
215
215
|
if (!this.doc || !pos || !this.schema) {
|
|
216
216
|
return false;
|
|
217
217
|
}
|
|
@@ -220,10 +220,13 @@ var RendererActions = /*#__PURE__*/function () {
|
|
|
220
220
|
var annotationId = annotation.annotationId,
|
|
221
221
|
annotationType = annotation.annotationType;
|
|
222
222
|
var step;
|
|
223
|
-
|
|
223
|
+
var beforeNodePos = isCommentsOnMediaBugFixEnabled ?
|
|
224
|
+
// As part of fix for RAP, `from` points to the position right before media node
|
|
225
|
+
// hence, -1 is not needed
|
|
226
|
+
from :
|
|
224
227
|
// If from points to a node position,
|
|
225
228
|
// we need to 1 position before it for nodeAt to return the node itself
|
|
226
|
-
|
|
229
|
+
Math.max(from - 1, 0);
|
|
227
230
|
var possibleNode = this.doc.nodeAt(beforeNodePos);
|
|
228
231
|
if ((possibleNode === null || possibleNode === void 0 ? void 0 : possibleNode.type.name) === 'media') {
|
|
229
232
|
step = new AddNodeMarkStep(beforeNodePos, this.schema.marks.annotation.create({
|
package/dist/esm/react/index.js
CHANGED
|
@@ -374,7 +374,7 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
374
374
|
var childHasLink = node.firstChild && node.firstChild.marks.filter(function (m) {
|
|
375
375
|
return isLinkMark(m) || _this5.allowMediaLinking === true;
|
|
376
376
|
}).length;
|
|
377
|
-
return _objectSpread(_objectSpread({}, this.getProps(node)), {}, {
|
|
377
|
+
return _objectSpread(_objectSpread({}, this.getProps(node, path)), {}, {
|
|
378
378
|
isInsideOfBlockNode: isInsideOfBlockNode,
|
|
379
379
|
childHasLink: childHasLink,
|
|
380
380
|
allowCaptions: this.media && this.media.allowCaptions,
|
|
@@ -17,7 +17,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
17
17
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
18
18
|
/** @jsx jsx */
|
|
19
19
|
|
|
20
|
-
import React, { PureComponent, Fragment, useEffect, useState, useMemo } from 'react';
|
|
20
|
+
import React, { PureComponent, Fragment, useEffect, useState, useMemo, useContext } from 'react';
|
|
21
21
|
import { jsx, css } from '@emotion/react';
|
|
22
22
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
23
23
|
import { MEDIA_CONTEXT } from '@atlaskit/analytics-namespaced-context';
|
|
@@ -30,7 +30,7 @@ import { getEventHandler } from '../../../utils';
|
|
|
30
30
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
31
31
|
import { MODE, PLATFORM } from '../../../analytics/events';
|
|
32
32
|
import AnnotationComponent from '../../marks/annotation';
|
|
33
|
-
import { AnnotationsDraftContext } from '../../../ui/annotations/context';
|
|
33
|
+
import { AnnotationsDraftContext, ProvidersContext } from '../../../ui/annotations/context';
|
|
34
34
|
import { CommentBadge as CommentBadgeComponent } from '@atlaskit/editor-common/media-single';
|
|
35
35
|
import { injectIntl } from 'react-intl-next';
|
|
36
36
|
import { useInlineCommentSubscriberContext, useInlineCommentsFilter } from '../../../ui/annotations/hooks';
|
|
@@ -284,6 +284,8 @@ var Media = /*#__PURE__*/function (_PureComponent) {
|
|
|
284
284
|
}(PureComponent);
|
|
285
285
|
var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
286
286
|
var draftPosition = React.useContext(AnnotationsDraftContext);
|
|
287
|
+
var providers = useContext(ProvidersContext);
|
|
288
|
+
var isCommentsOnMediaBugFixEnabled = !!(providers !== null && providers !== void 0 && providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
287
289
|
var dataAttributes = props.dataAttributes;
|
|
288
290
|
var pos = dataAttributes && dataAttributes['data-renderer-start-pos'];
|
|
289
291
|
var _useState5 = useState(),
|
|
@@ -295,17 +297,19 @@ var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
|
295
297
|
shouldApplyDraftAnnotation = _useState8[0],
|
|
296
298
|
setShouldApplyDraftAnnotation = _useState8[1];
|
|
297
299
|
useEffect(function () {
|
|
300
|
+
var _draftPosition$from;
|
|
298
301
|
if (pos === undefined) {
|
|
299
302
|
return;
|
|
300
303
|
}
|
|
301
|
-
|
|
304
|
+
var posToCheck = isCommentsOnMediaBugFixEnabled ? ((_draftPosition$from = draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from) !== null && _draftPosition$from !== void 0 ? _draftPosition$from : 0) + 1 : draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from;
|
|
305
|
+
if (draftPosition !== null && posToCheck === pos) {
|
|
302
306
|
setShouldApplyDraftAnnotation(true);
|
|
303
|
-
setPosition(
|
|
307
|
+
setPosition(posToCheck);
|
|
304
308
|
} else if (draftPosition === null && shouldApplyDraftAnnotation) {
|
|
305
309
|
setShouldApplyDraftAnnotation(false);
|
|
306
310
|
setPosition(undefined);
|
|
307
311
|
}
|
|
308
|
-
}, [draftPosition, pos, shouldApplyDraftAnnotation]);
|
|
312
|
+
}, [draftPosition, pos, shouldApplyDraftAnnotation, isCommentsOnMediaBugFixEnabled]);
|
|
309
313
|
var applyDraftAnnotation = props.allowAnnotationsDraftMode && shouldApplyDraftAnnotation && position !== undefined;
|
|
310
314
|
var dataAttributesWithDraftAnnotation = useMemo(function () {
|
|
311
315
|
return applyDraftAnnotation ? _objectSpread(_objectSpread({}, dataAttributes), {}, {
|
package/dist/esm/steps/index.js
CHANGED
|
@@ -19,6 +19,16 @@ function findParent(element) {
|
|
|
19
19
|
}
|
|
20
20
|
return findParent(parentElement);
|
|
21
21
|
}
|
|
22
|
+
function findMediaParent(element) {
|
|
23
|
+
var parentElement = element.parentElement;
|
|
24
|
+
if (!parentElement || isRoot(parentElement)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (parentElement.dataset.nodeType === 'mediaSingle') {
|
|
28
|
+
return parentElement;
|
|
29
|
+
}
|
|
30
|
+
return findMediaParent(parentElement);
|
|
31
|
+
}
|
|
22
32
|
function findParentBeforePointer(element) {
|
|
23
33
|
var parentElement = element.parentElement;
|
|
24
34
|
if (isRoot(parentElement) || !parentElement) {
|
|
@@ -155,18 +165,28 @@ export function resolvePos(node, offset) {
|
|
|
155
165
|
}
|
|
156
166
|
return resolvedPos + offset;
|
|
157
167
|
}
|
|
158
|
-
export function getPosFromRange(range) {
|
|
168
|
+
export function getPosFromRange(range, isCommentsOnMediaBugFixEnabled) {
|
|
159
169
|
var startContainer = range.startContainer,
|
|
160
170
|
startOffset = range.startOffset,
|
|
161
171
|
endContainer = range.endContainer,
|
|
162
172
|
endOffset = range.endOffset;
|
|
163
|
-
var
|
|
164
|
-
if (
|
|
165
|
-
var pos
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
173
|
+
var possibleMediaElement = findParent(startContainer);
|
|
174
|
+
if (possibleMediaElement && getNodeType(possibleMediaElement) === 'media') {
|
|
175
|
+
var pos;
|
|
176
|
+
if (isCommentsOnMediaBugFixEnabled) {
|
|
177
|
+
var mediaSingleElement = findMediaParent(possibleMediaElement);
|
|
178
|
+
if (mediaSingleElement) {
|
|
179
|
+
pos = getStartPos(mediaSingleElement);
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
pos = getStartPos(possibleMediaElement);
|
|
183
|
+
}
|
|
184
|
+
if (pos !== undefined) {
|
|
185
|
+
return {
|
|
186
|
+
from: pos,
|
|
187
|
+
to: pos
|
|
188
|
+
};
|
|
189
|
+
}
|
|
170
190
|
}
|
|
171
191
|
var from = resolvePos(startContainer, startOffset);
|
|
172
192
|
var to = resolvePos(endContainer, endOffset);
|
|
@@ -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.21.0";
|
|
50
50
|
export var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
51
51
|
_inherits(Renderer, _PureComponent);
|
|
52
52
|
var _super = _createSuper(Renderer);
|
|
@@ -5,6 +5,7 @@ import { updateWindowSelectionAroundDraft } from '../draft';
|
|
|
5
5
|
import { FabricChannel } from '@atlaskit/analytics-listeners';
|
|
6
6
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
7
7
|
import { RendererContext as ActionsContext } from '../../RendererActionsContext';
|
|
8
|
+
import { ProvidersContext } from '../context';
|
|
8
9
|
export var Mounter = /*#__PURE__*/React.memo(function (props) {
|
|
9
10
|
var Component = props.component,
|
|
10
11
|
range = props.range,
|
|
@@ -23,6 +24,8 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
|
|
|
23
24
|
draftDocumentPosition = _useState2[0],
|
|
24
25
|
setDraftDocumentPosition = _useState2[1];
|
|
25
26
|
var actions = useContext(ActionsContext);
|
|
27
|
+
var providers = useContext(ProvidersContext);
|
|
28
|
+
var isCommentsOnMediaBugFixEnabled = Boolean(providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
26
29
|
var onCreateCallback = useCallback(function (annotationId) {
|
|
27
30
|
if (!isAnnotationAllowed || !documentPosition || !applyAnnotation) {
|
|
28
31
|
return false;
|
|
@@ -40,8 +43,8 @@ export var Mounter = /*#__PURE__*/React.memo(function (props) {
|
|
|
40
43
|
eventType: EVENT_TYPE.TRACK
|
|
41
44
|
}).fire(FabricChannel.editor);
|
|
42
45
|
}
|
|
43
|
-
return applyAnnotation(draftDocumentPosition || documentPosition, annotation);
|
|
44
|
-
}, [isAnnotationAllowed, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent]);
|
|
46
|
+
return applyAnnotation(draftDocumentPosition || documentPosition, annotation, isCommentsOnMediaBugFixEnabled);
|
|
47
|
+
}, [isAnnotationAllowed, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent, isCommentsOnMediaBugFixEnabled]);
|
|
45
48
|
var createIndexCallback = useCallback(function () {
|
|
46
49
|
if (!documentPosition || !generateIndexMatch) {
|
|
47
50
|
return false;
|
|
@@ -3,7 +3,9 @@ import { Mounter } from './mounter';
|
|
|
3
3
|
import { RendererContext as ActionsContext } from '../../RendererActionsContext';
|
|
4
4
|
import { useAnnotationRangeDispatch, useAnnotationRangeState } from '../contexts/AnnotationRangeContext';
|
|
5
5
|
import { useAnnotationHoverContext } from '../contexts/AnnotationHoverContext';
|
|
6
|
+
import { ProvidersContext } from '../context';
|
|
6
7
|
export var RangeValidator = function RangeValidator(props) {
|
|
8
|
+
var _providers$inlineComm;
|
|
7
9
|
var component = props.component,
|
|
8
10
|
rendererRef = props.rendererRef,
|
|
9
11
|
applyAnnotationDraftAt = props.applyAnnotationDraftAt,
|
|
@@ -17,10 +19,12 @@ export var RangeValidator = function RangeValidator(props) {
|
|
|
17
19
|
type = _useAnnotationRangeSt.type;
|
|
18
20
|
var _useAnnotationHoverCo = useAnnotationHoverContext(),
|
|
19
21
|
isWithinRange = _useAnnotationHoverCo.isWithinRange;
|
|
22
|
+
var providers = useContext(ProvidersContext);
|
|
23
|
+
var isCommentsOnMediaBugFixEnabled = (_providers$inlineComm = providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugFixEnabled) !== null && _providers$inlineComm !== void 0 ? _providers$inlineComm : false;
|
|
20
24
|
if (!range || type !== 'hover') {
|
|
21
25
|
return null;
|
|
22
26
|
}
|
|
23
|
-
var documentPosition = actions.getPositionFromRange(range);
|
|
27
|
+
var documentPosition = actions.getPositionFromRange(range, isCommentsOnMediaBugFixEnabled);
|
|
24
28
|
return /*#__PURE__*/React.createElement(Mounter, {
|
|
25
29
|
isWithinRange: isWithinRange,
|
|
26
30
|
range: range,
|
|
@@ -5,6 +5,7 @@ import { updateWindowSelectionAroundDraft } from '../draft';
|
|
|
5
5
|
import { FabricChannel } from '@atlaskit/analytics-listeners';
|
|
6
6
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
7
7
|
import { RendererContext as ActionsContext } from '../../RendererActionsContext';
|
|
8
|
+
import { ProvidersContext } from '../context';
|
|
8
9
|
export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (props) {
|
|
9
10
|
var Component = props.component,
|
|
10
11
|
range = props.range,
|
|
@@ -23,6 +24,8 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
|
|
|
23
24
|
draftDocumentPosition = _useState2[0],
|
|
24
25
|
setDraftDocumentPosition = _useState2[1];
|
|
25
26
|
var actions = useContext(ActionsContext);
|
|
27
|
+
var providers = useContext(ProvidersContext);
|
|
28
|
+
var isCommentsOnMediaBugFixEnabled = !!(providers !== null && providers !== void 0 && providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
26
29
|
var onCreateCallback = useCallback(function (annotationId) {
|
|
27
30
|
// We want to support creation on a documentPosition if the user is only using ranges
|
|
28
31
|
// but we want to prioritize draft positions if they are being used by consumers
|
|
@@ -49,8 +52,8 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
|
|
|
49
52
|
eventType: EVENT_TYPE.TRACK
|
|
50
53
|
}).fire(FabricChannel.editor);
|
|
51
54
|
}
|
|
52
|
-
return applyAnnotation(positionToAnnotate, annotation);
|
|
53
|
-
}, [actions, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent]);
|
|
55
|
+
return applyAnnotation(positionToAnnotate, annotation, isCommentsOnMediaBugFixEnabled);
|
|
56
|
+
}, [actions, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent, isCommentsOnMediaBugFixEnabled]);
|
|
54
57
|
var createIndexCallback = useCallback(function () {
|
|
55
58
|
if (!documentPosition || !generateIndexMatch) {
|
|
56
59
|
return false;
|
|
@@ -3,6 +3,7 @@ import React, { useContext } from 'react';
|
|
|
3
3
|
import { useUserSelectionRange } from '../hooks/user-selection';
|
|
4
4
|
import { SelectionInlineCommentMounter } from './mounter';
|
|
5
5
|
import { RendererContext as ActionsContext } from '../../RendererActionsContext';
|
|
6
|
+
import { ProvidersContext } from '../context';
|
|
6
7
|
export var SelectionRangeValidator = function SelectionRangeValidator(props) {
|
|
7
8
|
var selectionComponent = props.selectionComponent,
|
|
8
9
|
rendererRef = props.rendererRef,
|
|
@@ -17,10 +18,12 @@ export var SelectionRangeValidator = function SelectionRangeValidator(props) {
|
|
|
17
18
|
range = _useUserSelectionRang2[0],
|
|
18
19
|
draftRange = _useUserSelectionRang2[1],
|
|
19
20
|
clearRange = _useUserSelectionRang2[2];
|
|
21
|
+
var providers = useContext(ProvidersContext);
|
|
22
|
+
var isCommentsOnMediaBugFixEnabled = Boolean(providers === null || providers === void 0 ? void 0 : providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
20
23
|
if (!range && !draftRange) {
|
|
21
24
|
return null;
|
|
22
25
|
}
|
|
23
|
-
var documentPosition = actions.getPositionFromRange(range);
|
|
26
|
+
var documentPosition = actions.getPositionFromRange(range, isCommentsOnMediaBugFixEnabled);
|
|
24
27
|
|
|
25
28
|
// This property is drilled down to consumers when a new range is selected to test it's validity
|
|
26
29
|
var isAnnotationAllowedOnRange = false;
|
|
@@ -22,7 +22,7 @@ export interface RendererActionsOptions {
|
|
|
22
22
|
deleteAnnotation: (annotationId: string, annotationType: 'inlineComment') => ActionResult;
|
|
23
23
|
isValidAnnotationRange: (range: Range) => boolean;
|
|
24
24
|
}
|
|
25
|
-
export type ApplyAnnotation = (pos: Position, annotation: Annotation) => AnnotationActionResult;
|
|
25
|
+
export type ApplyAnnotation = (pos: Position, annotation: Annotation, isCommentsOnMediaBugFixEnabled?: boolean) => AnnotationActionResult;
|
|
26
26
|
export interface AnnotationsRendererActionsOptions {
|
|
27
27
|
isValidAnnotationPosition: (pos: Position) => boolean;
|
|
28
28
|
applyAnnotation: ApplyAnnotation;
|
|
@@ -52,10 +52,10 @@ export default class RendererActions implements RendererActionsOptions, Annotati
|
|
|
52
52
|
annotate(range: Range, annotationId: string, annotationType: 'inlineComment'): AnnotationActionResult;
|
|
53
53
|
isValidAnnotationRange(range: Range | null): boolean;
|
|
54
54
|
isValidAnnotationPosition(pos: Position): boolean;
|
|
55
|
-
getPositionFromRange(range: Range | null): Position | false;
|
|
55
|
+
getPositionFromRange(range: Range | null, isCommentsOnMediaBugFixEnabled?: boolean): Position | false;
|
|
56
56
|
getAnnotationMarks(): Mark[];
|
|
57
57
|
getAnnotationsByPosition(range: Range): string[];
|
|
58
|
-
applyAnnotation(pos: Position, annotation: Annotation): AnnotationActionResult;
|
|
58
|
+
applyAnnotation(pos: Position, annotation: Annotation, isCommentsOnMediaBugFixEnabled?: boolean): AnnotationActionResult;
|
|
59
59
|
generateAnnotationIndexMatch(pos: Position): AnnotationByMatches | false;
|
|
60
60
|
}
|
|
61
61
|
export {};
|
|
@@ -6,7 +6,7 @@ interface AnnotationStepOptions {
|
|
|
6
6
|
annotationId: string;
|
|
7
7
|
annotationType: 'inlineComment';
|
|
8
8
|
}
|
|
9
|
-
export declare function getPosFromRange(range: Range): {
|
|
9
|
+
export declare function getPosFromRange(range: Range, isCommentsOnMediaBugFixEnabled?: boolean): {
|
|
10
10
|
from: number;
|
|
11
11
|
to: number;
|
|
12
12
|
} | false;
|
|
@@ -22,7 +22,7 @@ export interface RendererActionsOptions {
|
|
|
22
22
|
deleteAnnotation: (annotationId: string, annotationType: 'inlineComment') => ActionResult;
|
|
23
23
|
isValidAnnotationRange: (range: Range) => boolean;
|
|
24
24
|
}
|
|
25
|
-
export type ApplyAnnotation = (pos: Position, annotation: Annotation) => AnnotationActionResult;
|
|
25
|
+
export type ApplyAnnotation = (pos: Position, annotation: Annotation, isCommentsOnMediaBugFixEnabled?: boolean) => AnnotationActionResult;
|
|
26
26
|
export interface AnnotationsRendererActionsOptions {
|
|
27
27
|
isValidAnnotationPosition: (pos: Position) => boolean;
|
|
28
28
|
applyAnnotation: ApplyAnnotation;
|
|
@@ -52,10 +52,10 @@ export default class RendererActions implements RendererActionsOptions, Annotati
|
|
|
52
52
|
annotate(range: Range, annotationId: string, annotationType: 'inlineComment'): AnnotationActionResult;
|
|
53
53
|
isValidAnnotationRange(range: Range | null): boolean;
|
|
54
54
|
isValidAnnotationPosition(pos: Position): boolean;
|
|
55
|
-
getPositionFromRange(range: Range | null): Position | false;
|
|
55
|
+
getPositionFromRange(range: Range | null, isCommentsOnMediaBugFixEnabled?: boolean): Position | false;
|
|
56
56
|
getAnnotationMarks(): Mark[];
|
|
57
57
|
getAnnotationsByPosition(range: Range): string[];
|
|
58
|
-
applyAnnotation(pos: Position, annotation: Annotation): AnnotationActionResult;
|
|
58
|
+
applyAnnotation(pos: Position, annotation: Annotation, isCommentsOnMediaBugFixEnabled?: boolean): AnnotationActionResult;
|
|
59
59
|
generateAnnotationIndexMatch(pos: Position): AnnotationByMatches | false;
|
|
60
60
|
}
|
|
61
61
|
export {};
|
|
@@ -6,7 +6,7 @@ interface AnnotationStepOptions {
|
|
|
6
6
|
annotationId: string;
|
|
7
7
|
annotationType: 'inlineComment';
|
|
8
8
|
}
|
|
9
|
-
export declare function getPosFromRange(range: Range): {
|
|
9
|
+
export declare function getPosFromRange(range: Range, isCommentsOnMediaBugFixEnabled?: boolean): {
|
|
10
10
|
from: number;
|
|
11
11
|
to: number;
|
|
12
12
|
} | false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "109.
|
|
3
|
+
"version": "109.21.0",
|
|
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.3.0",
|
|
32
32
|
"@atlaskit/button": "^17.14.0",
|
|
33
33
|
"@atlaskit/code": "^15.1.0",
|
|
34
|
-
"@atlaskit/editor-common": "^78.
|
|
34
|
+
"@atlaskit/editor-common": "^78.34.0",
|
|
35
35
|
"@atlaskit/editor-json-transformer": "^8.11.0",
|
|
36
36
|
"@atlaskit/editor-palette": "1.5.3",
|
|
37
37
|
"@atlaskit/editor-prosemirror": "4.0.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@atlaskit/status": "^1.4.0",
|
|
52
52
|
"@atlaskit/task-decision": "^17.9.0",
|
|
53
53
|
"@atlaskit/theme": "^12.7.0",
|
|
54
|
-
"@atlaskit/tokens": "^1.
|
|
54
|
+
"@atlaskit/tokens": "^1.44.0",
|
|
55
55
|
"@atlaskit/tooltip": "^18.2.0",
|
|
56
56
|
"@babel/runtime": "^7.0.0",
|
|
57
57
|
"@emotion/react": "^11.7.1",
|