@atlaskit/renderer 111.0.1 → 111.1.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 +21 -0
- package/dist/cjs/actions/index.js +4 -7
- package/dist/cjs/react/index.js +12 -3
- package/dist/cjs/react/nodes/bodiedExtension.js +6 -1
- package/dist/cjs/react/nodes/media/index.js +2 -4
- package/dist/cjs/ui/Renderer/index.js +62 -12
- package/dist/cjs/ui/annotations/hover/mounter.js +4 -7
- package/dist/cjs/ui/annotations/index.js +9 -1
- package/dist/cjs/ui/annotations/selection/mounter.js +4 -7
- package/dist/es2019/actions/index.js +5 -8
- package/dist/es2019/react/index.js +12 -3
- package/dist/es2019/react/nodes/bodiedExtension.js +6 -1
- package/dist/es2019/react/nodes/media/index.js +4 -6
- package/dist/es2019/ui/Renderer/index.js +55 -6
- package/dist/es2019/ui/annotations/hover/mounter.js +4 -7
- package/dist/es2019/ui/annotations/index.js +8 -0
- package/dist/es2019/ui/annotations/selection/mounter.js +4 -7
- package/dist/esm/actions/index.js +4 -7
- package/dist/esm/react/index.js +12 -3
- package/dist/esm/react/nodes/bodiedExtension.js +6 -1
- package/dist/esm/react/nodes/media/index.js +4 -6
- package/dist/esm/ui/Renderer/index.js +60 -12
- package/dist/esm/ui/annotations/hover/mounter.js +4 -7
- package/dist/esm/ui/annotations/index.js +8 -0
- package/dist/esm/ui/annotations/selection/mounter.js +4 -7
- package/dist/types/actions/index.d.ts +2 -2
- package/dist/types/react/index.d.ts +7 -0
- package/dist/types/react/nodes/bodiedExtension.d.ts +1 -0
- package/dist/types/ui/Renderer/index.d.ts +13 -3
- package/dist/types/ui/annotations/index.d.ts +4 -1
- package/dist/types/ui/annotations/types.d.ts +8 -0
- package/dist/types-ts4.5/actions/index.d.ts +2 -2
- package/dist/types-ts4.5/react/index.d.ts +7 -0
- package/dist/types-ts4.5/react/nodes/bodiedExtension.d.ts +1 -0
- package/dist/types-ts4.5/ui/Renderer/index.d.ts +13 -3
- package/dist/types-ts4.5/ui/annotations/index.d.ts +4 -1
- package/dist/types-ts4.5/ui/annotations/types.d.ts +8 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 111.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#147660](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147660)
|
|
8
|
+
[`a407a8fbc874b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a407a8fbc874b) -
|
|
9
|
+
ED-24365 Support commenting inside bodied extension content in the Renderer
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 111.0.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#147547](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147547)
|
|
20
|
+
[`46defc30fb9dd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/46defc30fb9dd) -
|
|
21
|
+
Cleanup of a FF for comments on media bug fix
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 111.0.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -281,7 +281,7 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
281
281
|
}
|
|
282
282
|
}, {
|
|
283
283
|
key: "applyAnnotation",
|
|
284
|
-
value: function applyAnnotation(pos, annotation
|
|
284
|
+
value: function applyAnnotation(pos, annotation) {
|
|
285
285
|
if (!this.doc || !pos || !this.schema) {
|
|
286
286
|
return false;
|
|
287
287
|
}
|
|
@@ -291,13 +291,10 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
291
291
|
annotationType = annotation.annotationType;
|
|
292
292
|
var step;
|
|
293
293
|
var targetNodeType;
|
|
294
|
-
|
|
294
|
+
|
|
295
295
|
// As part of fix for RAP, `from` points to the position right before media node
|
|
296
296
|
// hence, -1 is not needed
|
|
297
|
-
from
|
|
298
|
-
// If from points to a node position,
|
|
299
|
-
// we need to 1 position before it for nodeAt to return the node itself
|
|
300
|
-
Math.max(from - 1, 0);
|
|
297
|
+
var beforeNodePos = from;
|
|
301
298
|
var possibleNode = this.doc.nodeAt(beforeNodePos);
|
|
302
299
|
if ((possibleNode === null || possibleNode === void 0 ? void 0 : possibleNode.type.name) === 'media') {
|
|
303
300
|
targetNodeType = 'media';
|
|
@@ -340,7 +337,7 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
340
337
|
numMatches: numMatches,
|
|
341
338
|
matchIndex: matchIndex,
|
|
342
339
|
pos: blockNodePos
|
|
343
|
-
},
|
|
340
|
+
}, {
|
|
344
341
|
targetNodeType: targetNodeType
|
|
345
342
|
});
|
|
346
343
|
}
|
package/dist/cjs/react/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
13
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
14
|
var _react = _interopRequireDefault(require("react"));
|
|
15
15
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
16
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
16
17
|
var _links = require("./utils/links");
|
|
17
18
|
var _nodes = require("./nodes");
|
|
18
19
|
var _textWrapper = _interopRequireDefault(require("./nodes/text-wrapper"));
|
|
@@ -57,7 +58,6 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
|
|
|
57
58
|
(0, _defineProperty2.default)(this, "allowWrapCodeBlock", false);
|
|
58
59
|
(0, _defineProperty2.default)(this, "allowPlaceholderText", true);
|
|
59
60
|
(0, _defineProperty2.default)(this, "allowCustomPanels", false);
|
|
60
|
-
(0, _defineProperty2.default)(this, "startPos", 1);
|
|
61
61
|
(0, _defineProperty2.default)(this, "surroundTextNodesWithTextWrapper", false);
|
|
62
62
|
(0, _defineProperty2.default)(this, "allowAnnotations", false);
|
|
63
63
|
(0, _defineProperty2.default)(this, "serializeFragmentChild", function (node, _ref) {
|
|
@@ -161,6 +161,13 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
|
|
|
161
161
|
});
|
|
162
162
|
return props;
|
|
163
163
|
});
|
|
164
|
+
if ((0, _experiments.editorExperiment)('comment_on_bodied_extensions', true)) {
|
|
165
|
+
this.initStartPos = init.startPos || 1;
|
|
166
|
+
this.startPos = init.startPos || 1;
|
|
167
|
+
} else {
|
|
168
|
+
this.initStartPos = 1;
|
|
169
|
+
this.startPos = 1;
|
|
170
|
+
}
|
|
164
171
|
this.providers = init.providers;
|
|
165
172
|
this.eventHandlers = init.eventHandlers;
|
|
166
173
|
this.extensionHandlers = init.extensionHandlers;
|
|
@@ -198,7 +205,7 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
|
|
|
198
205
|
value: function resetState() {
|
|
199
206
|
this.headingIds = [];
|
|
200
207
|
this.expandHeadingIds = [];
|
|
201
|
-
this.startPos =
|
|
208
|
+
this.startPos = this.initStartPos;
|
|
202
209
|
}
|
|
203
210
|
}, {
|
|
204
211
|
key: "getNodeProps",
|
|
@@ -531,6 +538,7 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
|
|
|
531
538
|
key: "getProps",
|
|
532
539
|
value: function getProps(node) {
|
|
533
540
|
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
541
|
+
var startPos = this.startPos + path.length;
|
|
534
542
|
return _objectSpread({
|
|
535
543
|
text: node.text,
|
|
536
544
|
providers: this.providers,
|
|
@@ -553,8 +561,9 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
|
|
|
553
561
|
dataAttributes: {
|
|
554
562
|
// We need to account for depth (path.length gives up depth) here
|
|
555
563
|
// but depth doesnt increment the pos, only accounted for.
|
|
556
|
-
'data-renderer-start-pos':
|
|
564
|
+
'data-renderer-start-pos': startPos
|
|
557
565
|
},
|
|
566
|
+
startPos: startPos,
|
|
558
567
|
path: path
|
|
559
568
|
}, node.attrs);
|
|
560
569
|
}
|
|
@@ -13,6 +13,7 @@ var _ErrorBoundary = require("../../ui/Renderer/ErrorBoundary");
|
|
|
13
13
|
var _ExtensionRenderer = _interopRequireDefault(require("../../ui/ExtensionRenderer"));
|
|
14
14
|
var _enums = require("../../analytics/enums");
|
|
15
15
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
16
|
+
var _annotations = require("../../ui/annotations");
|
|
16
17
|
var BodiedExtension = function BodiedExtension(props) {
|
|
17
18
|
var children = props.children,
|
|
18
19
|
_props$layout = props.layout,
|
|
@@ -31,6 +32,10 @@ var BodiedExtension = function BodiedExtension(props) {
|
|
|
31
32
|
componentId: _analytics.ACTION_SUBJECT_ID.EXTENSION_BODIED,
|
|
32
33
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
33
34
|
additionalInfo: "".concat(extensionType, ": ").concat(extensionKey, " ")
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement(_annotations.AnnotationsPositionContext.Provider, {
|
|
36
|
+
value: {
|
|
37
|
+
startPos: props.startPos + 1
|
|
38
|
+
}
|
|
34
39
|
}, /*#__PURE__*/_react.default.createElement(_ExtensionRenderer.default, (0, _extends2.default)({}, props, {
|
|
35
40
|
type: "bodiedExtension"
|
|
36
41
|
}), function (_ref) {
|
|
@@ -51,6 +56,6 @@ var BodiedExtension = function BodiedExtension(props) {
|
|
|
51
56
|
return (0, _extension.renderExtension)(children, layout, {
|
|
52
57
|
isTopLevel: path.length < 1
|
|
53
58
|
}, removeOverflow);
|
|
54
|
-
}));
|
|
59
|
+
})));
|
|
55
60
|
};
|
|
56
61
|
var _default = exports.default = BodiedExtension;
|
|
@@ -407,8 +407,6 @@ var Media = /*#__PURE__*/function (_PureComponent) {
|
|
|
407
407
|
}(_react.PureComponent);
|
|
408
408
|
var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
409
409
|
var draftPosition = _react.default.useContext(_context.AnnotationsDraftContext);
|
|
410
|
-
var providers = (0, _react.useContext)(_context.ProvidersContext);
|
|
411
|
-
var isCommentsOnMediaBugFixEnabled = !!(providers !== null && providers !== void 0 && providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
412
410
|
var dataAttributes = props.dataAttributes;
|
|
413
411
|
var pos = dataAttributes && dataAttributes['data-renderer-start-pos'];
|
|
414
412
|
var _useState9 = (0, _react.useState)(),
|
|
@@ -424,7 +422,7 @@ var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
|
424
422
|
if (pos === undefined) {
|
|
425
423
|
return;
|
|
426
424
|
}
|
|
427
|
-
var posToCheck =
|
|
425
|
+
var posToCheck = ((_draftPosition$from = draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from) !== null && _draftPosition$from !== void 0 ? _draftPosition$from : 0) + 1;
|
|
428
426
|
if (draftPosition !== null && posToCheck === pos) {
|
|
429
427
|
setShouldApplyDraftAnnotation(true);
|
|
430
428
|
setPosition(posToCheck);
|
|
@@ -432,7 +430,7 @@ var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
|
432
430
|
setShouldApplyDraftAnnotation(false);
|
|
433
431
|
setPosition(undefined);
|
|
434
432
|
}
|
|
435
|
-
}, [draftPosition, pos, shouldApplyDraftAnnotation
|
|
433
|
+
}, [draftPosition, pos, shouldApplyDraftAnnotation]);
|
|
436
434
|
var applyDraftAnnotation = props.allowAnnotationsDraftMode && shouldApplyDraftAnnotation && position !== undefined;
|
|
437
435
|
var dataAttributesWithDraftAnnotation = (0, _react.useMemo)(function () {
|
|
438
436
|
return applyDraftAnnotation ? _objectSpread(_objectSpread({}, dataAttributes), {}, {
|
|
@@ -5,7 +5,9 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.NORMAL_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = void 0;
|
|
9
|
+
exports.Renderer = Renderer;
|
|
10
|
+
exports.defaultNodeComponents = exports.default = exports.__RendererClassComponent = exports.RendererWithAnalytics = void 0;
|
|
9
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -19,6 +21,7 @@ var _react2 = require("@emotion/react");
|
|
|
19
21
|
var _schemaDefault = require("@atlaskit/adf-schema/schema-default");
|
|
20
22
|
var _traverse = require("@atlaskit/adf-utils/traverse");
|
|
21
23
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
24
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
22
25
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
23
26
|
var _performanceMeasures = require("@atlaskit/editor-common/performance-measures");
|
|
24
27
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
@@ -63,14 +66,18 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
63
66
|
var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
64
67
|
var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
65
68
|
var packageName = "@atlaskit/renderer";
|
|
66
|
-
var packageVersion = "111.0
|
|
69
|
+
var packageVersion = "111.1.0";
|
|
67
70
|
var defaultNodeComponents = exports.defaultNodeComponents = _nodes.nodeToReact;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Exported due to enzyme test reliance on this component.
|
|
74
|
+
*/
|
|
75
|
+
var __RendererClassComponent = exports.__RendererClassComponent = /*#__PURE__*/function (_PureComponent) {
|
|
76
|
+
(0, _inherits2.default)(__RendererClassComponent, _PureComponent);
|
|
77
|
+
var _super = _createSuper(__RendererClassComponent);
|
|
78
|
+
function __RendererClassComponent(props) {
|
|
72
79
|
var _this;
|
|
73
|
-
(0, _classCallCheck2.default)(this,
|
|
80
|
+
(0, _classCallCheck2.default)(this, __RendererClassComponent);
|
|
74
81
|
_this = _super.call(this, props);
|
|
75
82
|
/**
|
|
76
83
|
* This is used in measuring the Renderer Mount time and is then
|
|
@@ -169,7 +176,7 @@ var Renderer = exports.Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
169
176
|
}
|
|
170
177
|
return _this;
|
|
171
178
|
}
|
|
172
|
-
(0, _createClass2.default)(
|
|
179
|
+
(0, _createClass2.default)(__RendererClassComponent, [{
|
|
173
180
|
key: "anchorLinkAnalytics",
|
|
174
181
|
value: function anchorLinkAnalytics() {
|
|
175
182
|
var hash = window.location.hash && decodeURIComponent(window.location.hash.slice(1));
|
|
@@ -257,6 +264,7 @@ var Renderer = exports.Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
257
264
|
var _this$featureFlags = this.featureFlags(props.featureFlags),
|
|
258
265
|
featureFlags = _this$featureFlags.featureFlags;
|
|
259
266
|
return {
|
|
267
|
+
startPos: props.startPos,
|
|
260
268
|
providers: this.providerFactory,
|
|
261
269
|
eventHandlers: props.eventHandlers,
|
|
262
270
|
extensionHandlers: props.extensionHandlers,
|
|
@@ -445,8 +453,21 @@ var Renderer = exports.Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
445
453
|
}
|
|
446
454
|
}
|
|
447
455
|
}]);
|
|
448
|
-
return
|
|
456
|
+
return __RendererClassComponent;
|
|
449
457
|
}(_react.PureComponent);
|
|
458
|
+
function Renderer(props) {
|
|
459
|
+
var _React$useContext = _react.default.useContext(_annotations.AnnotationsPositionContext),
|
|
460
|
+
startPos = _React$useContext.startPos;
|
|
461
|
+
|
|
462
|
+
// eslint-disable-next-line react/jsx-pascal-case
|
|
463
|
+
return (0, _react2.jsx)(__RendererClassComponent, (0, _extends2.default)({}, props, {
|
|
464
|
+
startPos: startPos
|
|
465
|
+
}));
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// Usage notes:
|
|
469
|
+
// Used by Confluence for View page renderer
|
|
470
|
+
// For the nested renderers - see RendererWithAnnotationSelection.
|
|
450
471
|
var RendererWithAnalytics = exports.RendererWithAnalytics = /*#__PURE__*/_react.default.memo(function (props) {
|
|
451
472
|
return (0, _react2.jsx)(_analyticsNamespacedContext.FabricEditorAnalyticsContext, {
|
|
452
473
|
data: {
|
|
@@ -560,25 +581,54 @@ var RendererWrapper = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
560
581
|
})
|
|
561
582
|
}, children))));
|
|
562
583
|
});
|
|
584
|
+
var RootRendererContext = /*#__PURE__*/_react.default.createContext(null);
|
|
563
585
|
function RendererActionsInternalUpdater(_ref) {
|
|
564
586
|
var children = _ref.children,
|
|
565
587
|
doc = _ref.doc,
|
|
566
588
|
schema = _ref.schema,
|
|
567
589
|
onAnalyticsEvent = _ref.onAnalyticsEvent;
|
|
590
|
+
var rootRendererContextValue = _react.default.useContext(RootRendererContext);
|
|
568
591
|
var actions = (0, _react.useContext)(_RendererActionsContext.RendererContext);
|
|
569
592
|
var rendererRef = (0, _react.useRef)(null);
|
|
593
|
+
|
|
594
|
+
// This doc is used by the renderer actions when applying comments to the document.
|
|
595
|
+
// (via hand crafted steps based on non prosemirror based position calculations)
|
|
596
|
+
// It is set to the root renderer's doc as otherwise the resulting document will
|
|
597
|
+
// be incorrect (nested renderers use a fake document which represents a subset
|
|
598
|
+
// of the actual document).
|
|
599
|
+
var _doc;
|
|
600
|
+
if ((0, _experiments.editorExperiment)('comment_on_bodied_extensions', true) && rootRendererContextValue) {
|
|
601
|
+
// If rootRendererContextValue is set -- we are inside a nested renderer
|
|
602
|
+
// and should always use the doc from the root renderer
|
|
603
|
+
_doc = rootRendererContextValue.doc;
|
|
604
|
+
} else {
|
|
605
|
+
// If rootRendererContextValue is not set -- we are in the root renderer
|
|
606
|
+
// and set the doc to the current doc.
|
|
607
|
+
_doc = doc;
|
|
608
|
+
}
|
|
570
609
|
(0, _react.useLayoutEffect)(function () {
|
|
571
|
-
if (
|
|
572
|
-
actions._privateRegisterRenderer(rendererRef,
|
|
610
|
+
if (_doc) {
|
|
611
|
+
actions._privateRegisterRenderer(rendererRef, _doc, schema, onAnalyticsEvent);
|
|
573
612
|
} else {
|
|
574
613
|
actions._privateUnregisterRenderer();
|
|
575
614
|
}
|
|
576
615
|
return function () {
|
|
577
616
|
return actions._privateUnregisterRenderer();
|
|
578
617
|
};
|
|
579
|
-
}, [actions, schema,
|
|
618
|
+
}, [actions, schema, _doc, onAnalyticsEvent]);
|
|
619
|
+
if ((0, _experiments.editorExperiment)('comment_on_bodied_extensions', true)) {
|
|
620
|
+
return (0, _react2.jsx)(RootRendererContext.Provider, {
|
|
621
|
+
value: {
|
|
622
|
+
doc: _doc
|
|
623
|
+
}
|
|
624
|
+
}, children);
|
|
625
|
+
}
|
|
580
626
|
return children;
|
|
581
627
|
}
|
|
628
|
+
|
|
629
|
+
// Usage notes:
|
|
630
|
+
// Used by Confluence for nested renderers
|
|
631
|
+
// For the View page renderer - see RendererWithAnalytics
|
|
582
632
|
var RendererWithAnnotationSelection = function RendererWithAnnotationSelection(props) {
|
|
583
633
|
var allowAnnotations = props.allowAnnotations,
|
|
584
634
|
adfDocument = props.document;
|
|
@@ -13,7 +13,6 @@ var _draft = require("../draft");
|
|
|
13
13
|
var _types = require("@atlaskit/analytics-listeners/types");
|
|
14
14
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
15
15
|
var _RendererActionsContext = require("../../RendererActionsContext");
|
|
16
|
-
var _context = require("../context");
|
|
17
16
|
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); }
|
|
18
17
|
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
18
|
var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props) {
|
|
@@ -34,8 +33,6 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
|
|
|
34
33
|
draftDocumentPosition = _useState2[0],
|
|
35
34
|
setDraftDocumentPosition = _useState2[1];
|
|
36
35
|
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);
|
|
39
36
|
var onCreateCallback = (0, _react.useCallback)(function (annotationId) {
|
|
40
37
|
if (!isAnnotationAllowed || !documentPosition || !applyAnnotation) {
|
|
41
38
|
return false;
|
|
@@ -53,8 +50,8 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
|
|
|
53
50
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
54
51
|
}).fire(_types.FabricChannel.editor);
|
|
55
52
|
}
|
|
56
|
-
return applyAnnotation(draftDocumentPosition || documentPosition, annotation
|
|
57
|
-
}, [isAnnotationAllowed, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent
|
|
53
|
+
return applyAnnotation(draftDocumentPosition || documentPosition, annotation);
|
|
54
|
+
}, [isAnnotationAllowed, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent]);
|
|
58
55
|
var createIndexCallback = (0, _react.useCallback)(function () {
|
|
59
56
|
if (!documentPosition || !generateIndexMatch) {
|
|
60
57
|
return false;
|
|
@@ -110,8 +107,8 @@ var Mounter = exports.Mounter = /*#__PURE__*/_react.default.memo(function (props
|
|
|
110
107
|
annotationId: options.annotationId,
|
|
111
108
|
annotationType: _adfSchema.AnnotationTypes.INLINE_COMMENT
|
|
112
109
|
};
|
|
113
|
-
return applyAnnotation(positionToAnnotate, annotation
|
|
114
|
-
}, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition,
|
|
110
|
+
return applyAnnotation(positionToAnnotate, annotation);
|
|
111
|
+
}, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition, actions, range]);
|
|
115
112
|
var removeDraftModeCallback = (0, _react.useCallback)(function () {
|
|
116
113
|
clearAnnotationDraft();
|
|
117
114
|
setDraftDocumentPosition(null);
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "AnnotationMark", {
|
|
|
10
10
|
return _element.MarkElement;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
exports.AnnotationsWrapper = void 0;
|
|
13
|
+
exports.AnnotationsWrapper = exports.AnnotationsPositionContext = void 0;
|
|
14
14
|
Object.defineProperty(exports, "TextWithAnnotationDraft", {
|
|
15
15
|
enumerable: true,
|
|
16
16
|
get: function get() {
|
|
@@ -40,6 +40,14 @@ var LoadAnnotations = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
|
40
40
|
});
|
|
41
41
|
return null;
|
|
42
42
|
});
|
|
43
|
+
|
|
44
|
+
// This is used by renderers when setting the data-start-pos attribute on commentable nodes
|
|
45
|
+
// By default it is 1 (the possible starting position of any document).
|
|
46
|
+
// The bodied extension component then sets a new value for this context based on its on position
|
|
47
|
+
// in the document.
|
|
48
|
+
var AnnotationsPositionContext = exports.AnnotationsPositionContext = /*#__PURE__*/_react.default.createContext({
|
|
49
|
+
startPos: 1
|
|
50
|
+
});
|
|
43
51
|
var AnnotationsWrapper = exports.AnnotationsWrapper = function AnnotationsWrapper(props) {
|
|
44
52
|
var _annotationProvider$i, _annotationProvider$i2;
|
|
45
53
|
var children = props.children,
|
|
@@ -15,7 +15,6 @@ var _types = require("@atlaskit/analytics-listeners/types");
|
|
|
15
15
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
16
16
|
var _getRendererRangeInlineNodeNames = require("../../../actions/get-renderer-range-inline-node-names");
|
|
17
17
|
var _RendererActionsContext = require("../../RendererActionsContext");
|
|
18
|
-
var _context = require("../context");
|
|
19
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
19
|
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; }
|
|
21
20
|
var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#__PURE__*/_react.default.memo(function (props) {
|
|
@@ -36,8 +35,6 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
36
35
|
draftDocumentPosition = _useState2[0],
|
|
37
36
|
setDraftDocumentPosition = _useState2[1];
|
|
38
37
|
var actions = (0, _react.useContext)(_RendererActionsContext.RendererContext);
|
|
39
|
-
var providers = (0, _react.useContext)(_context.ProvidersContext);
|
|
40
|
-
var isCommentsOnMediaBugFixEnabled = !!(providers !== null && providers !== void 0 && providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
41
38
|
var inlineNodeTypes = (0, _react.useMemo)(function () {
|
|
42
39
|
if ((0, _platformFeatureFlags.fg)('annotations_defensive_node_name_calculations')) {
|
|
43
40
|
if (!actions.isRangeAnnotatable(range)) {
|
|
@@ -89,8 +86,8 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
89
86
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
90
87
|
}).fire(_types.FabricChannel.editor);
|
|
91
88
|
}
|
|
92
|
-
return applyAnnotation(positionToAnnotate, annotation
|
|
93
|
-
}, [actions, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent,
|
|
89
|
+
return applyAnnotation(positionToAnnotate, annotation);
|
|
90
|
+
}, [actions, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent, inlineNodeTypes]);
|
|
94
91
|
var createIndexCallback = (0, _react.useCallback)(function () {
|
|
95
92
|
if (!documentPosition || !generateIndexMatch) {
|
|
96
93
|
return false;
|
|
@@ -149,8 +146,8 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
149
146
|
annotationId: options.annotationId,
|
|
150
147
|
annotationType: _adfSchema.AnnotationTypes.INLINE_COMMENT
|
|
151
148
|
};
|
|
152
|
-
return applyAnnotation(positionToAnnotate, annotation
|
|
153
|
-
}, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition,
|
|
149
|
+
return applyAnnotation(positionToAnnotate, annotation);
|
|
150
|
+
}, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, applyAnnotation, draftDocumentPosition, actions, range, inlineNodeTypes]);
|
|
154
151
|
var removeDraftModeCallback = (0, _react.useCallback)(function () {
|
|
155
152
|
clearAnnotationDraft();
|
|
156
153
|
setDraftDocumentPosition(null);
|
|
@@ -253,7 +253,7 @@ export default class RendererActions {
|
|
|
253
253
|
}
|
|
254
254
|
return getAnnotationIdsFromRange(pos, this.doc, this.schema);
|
|
255
255
|
}
|
|
256
|
-
applyAnnotation(pos, annotation
|
|
256
|
+
applyAnnotation(pos, annotation) {
|
|
257
257
|
if (!this.doc || !pos || !this.schema) {
|
|
258
258
|
return false;
|
|
259
259
|
}
|
|
@@ -267,13 +267,10 @@ export default class RendererActions {
|
|
|
267
267
|
} = annotation;
|
|
268
268
|
let step;
|
|
269
269
|
let targetNodeType;
|
|
270
|
-
|
|
270
|
+
|
|
271
271
|
// As part of fix for RAP, `from` points to the position right before media node
|
|
272
272
|
// hence, -1 is not needed
|
|
273
|
-
from
|
|
274
|
-
// If from points to a node position,
|
|
275
|
-
// we need to 1 position before it for nodeAt to return the node itself
|
|
276
|
-
Math.max(from - 1, 0);
|
|
273
|
+
const beforeNodePos = from;
|
|
277
274
|
const possibleNode = this.doc.nodeAt(beforeNodePos);
|
|
278
275
|
if ((possibleNode === null || possibleNode === void 0 ? void 0 : possibleNode.type.name) === 'media') {
|
|
279
276
|
targetNodeType = 'media';
|
|
@@ -318,9 +315,9 @@ export default class RendererActions {
|
|
|
318
315
|
numMatches,
|
|
319
316
|
matchIndex,
|
|
320
317
|
pos: blockNodePos,
|
|
321
|
-
...
|
|
318
|
+
...{
|
|
322
319
|
targetNodeType
|
|
323
|
-
}
|
|
320
|
+
}
|
|
324
321
|
};
|
|
325
322
|
}
|
|
326
323
|
generateAnnotationIndexMatch(pos) {
|
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { MarkType } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
import { isNestedHeaderLinksEnabled } from './utils/links';
|
|
6
7
|
import { Doc, DocWithSelectAllTrap, mergeTextNodes, isTextWrapper, isTextNode, toReact } from './nodes';
|
|
7
8
|
import TextWrapperComponent from './nodes/text-wrapper';
|
|
@@ -41,7 +42,6 @@ export default class ReactSerializer {
|
|
|
41
42
|
_defineProperty(this, "allowWrapCodeBlock", false);
|
|
42
43
|
_defineProperty(this, "allowPlaceholderText", true);
|
|
43
44
|
_defineProperty(this, "allowCustomPanels", false);
|
|
44
|
-
_defineProperty(this, "startPos", 1);
|
|
45
45
|
_defineProperty(this, "surroundTextNodesWithTextWrapper", false);
|
|
46
46
|
_defineProperty(this, "allowAnnotations", false);
|
|
47
47
|
_defineProperty(this, "serializeFragmentChild", (node, {
|
|
@@ -147,6 +147,13 @@ export default class ReactSerializer {
|
|
|
147
147
|
};
|
|
148
148
|
return props;
|
|
149
149
|
});
|
|
150
|
+
if (editorExperiment('comment_on_bodied_extensions', true)) {
|
|
151
|
+
this.initStartPos = init.startPos || 1;
|
|
152
|
+
this.startPos = init.startPos || 1;
|
|
153
|
+
} else {
|
|
154
|
+
this.initStartPos = 1;
|
|
155
|
+
this.startPos = 1;
|
|
156
|
+
}
|
|
150
157
|
this.providers = init.providers;
|
|
151
158
|
this.eventHandlers = init.eventHandlers;
|
|
152
159
|
this.extensionHandlers = init.extensionHandlers;
|
|
@@ -182,7 +189,7 @@ export default class ReactSerializer {
|
|
|
182
189
|
resetState() {
|
|
183
190
|
this.headingIds = [];
|
|
184
191
|
this.expandHeadingIds = [];
|
|
185
|
-
this.startPos =
|
|
192
|
+
this.startPos = this.initStartPos;
|
|
186
193
|
}
|
|
187
194
|
getNodeProps(node, parentInfo) {
|
|
188
195
|
const path = parentInfo ? parentInfo.path : undefined;
|
|
@@ -463,6 +470,7 @@ export default class ReactSerializer {
|
|
|
463
470
|
};
|
|
464
471
|
}
|
|
465
472
|
getProps(node, path = []) {
|
|
473
|
+
const startPos = this.startPos + path.length;
|
|
466
474
|
return {
|
|
467
475
|
text: node.text,
|
|
468
476
|
providers: this.providers,
|
|
@@ -485,8 +493,9 @@ export default class ReactSerializer {
|
|
|
485
493
|
dataAttributes: {
|
|
486
494
|
// We need to account for depth (path.length gives up depth) here
|
|
487
495
|
// but depth doesnt increment the pos, only accounted for.
|
|
488
|
-
'data-renderer-start-pos':
|
|
496
|
+
'data-renderer-start-pos': startPos
|
|
489
497
|
},
|
|
498
|
+
startPos,
|
|
490
499
|
path,
|
|
491
500
|
...node.attrs
|
|
492
501
|
};
|
|
@@ -6,6 +6,7 @@ import { ErrorBoundary } from '../../ui/Renderer/ErrorBoundary';
|
|
|
6
6
|
import ExtensionRenderer from '../../ui/ExtensionRenderer';
|
|
7
7
|
import { ACTION_SUBJECT } from '../../analytics/enums';
|
|
8
8
|
import { ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
9
|
+
import { AnnotationsPositionContext } from '../../ui/annotations';
|
|
9
10
|
const BodiedExtension = props => {
|
|
10
11
|
const {
|
|
11
12
|
children,
|
|
@@ -23,6 +24,10 @@ const BodiedExtension = props => {
|
|
|
23
24
|
componentId: ACTION_SUBJECT_ID.EXTENSION_BODIED,
|
|
24
25
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
25
26
|
additionalInfo: `${extensionType}: ${extensionKey} `
|
|
27
|
+
}, /*#__PURE__*/React.createElement(AnnotationsPositionContext.Provider, {
|
|
28
|
+
value: {
|
|
29
|
+
startPos: props.startPos + 1
|
|
30
|
+
}
|
|
26
31
|
}, /*#__PURE__*/React.createElement(ExtensionRenderer, _extends({}, props, {
|
|
27
32
|
type: "bodiedExtension"
|
|
28
33
|
}), ({
|
|
@@ -44,6 +49,6 @@ const BodiedExtension = props => {
|
|
|
44
49
|
return renderExtension(children, layout, {
|
|
45
50
|
isTopLevel: path.length < 1
|
|
46
51
|
}, removeOverflow);
|
|
47
|
-
}));
|
|
52
|
+
})));
|
|
48
53
|
};
|
|
49
54
|
export default BodiedExtension;
|
|
@@ -6,7 +6,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
6
6
|
* @jsxFrag
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import React, { PureComponent, Fragment, useEffect, useState, useMemo
|
|
9
|
+
import React, { PureComponent, Fragment, useEffect, useState, useMemo } from 'react';
|
|
10
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
11
|
import { jsx, css } from '@emotion/react';
|
|
12
12
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
@@ -20,7 +20,7 @@ import { getEventHandler } from '../../../utils';
|
|
|
20
20
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, VIEW_METHOD } from '@atlaskit/editor-common/analytics';
|
|
21
21
|
import { MODE, PLATFORM } from '../../../analytics/events';
|
|
22
22
|
import AnnotationComponent from '../../marks/annotation';
|
|
23
|
-
import { AnnotationsDraftContext
|
|
23
|
+
import { AnnotationsDraftContext } from '../../../ui/annotations/context';
|
|
24
24
|
import { CommentBadge as CommentBadgeComponent, CommentBadgeNext, ExternalImageBadge, MediaBadges } from '@atlaskit/editor-common/media-single';
|
|
25
25
|
import { injectIntl } from 'react-intl-next';
|
|
26
26
|
import { useInlineCommentSubscriberContext, useInlineCommentsFilter } from '../../../ui/annotations/hooks';
|
|
@@ -371,8 +371,6 @@ class Media extends PureComponent {
|
|
|
371
371
|
}
|
|
372
372
|
const MediaWithDraftAnnotation = props => {
|
|
373
373
|
const draftPosition = React.useContext(AnnotationsDraftContext);
|
|
374
|
-
const providers = useContext(ProvidersContext);
|
|
375
|
-
const isCommentsOnMediaBugFixEnabled = !!(providers !== null && providers !== void 0 && providers.inlineComment.isCommentsOnMediaBugFixEnabled);
|
|
376
374
|
const {
|
|
377
375
|
dataAttributes
|
|
378
376
|
} = props;
|
|
@@ -384,7 +382,7 @@ const MediaWithDraftAnnotation = props => {
|
|
|
384
382
|
if (pos === undefined) {
|
|
385
383
|
return;
|
|
386
384
|
}
|
|
387
|
-
const posToCheck =
|
|
385
|
+
const posToCheck = ((_draftPosition$from = draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from) !== null && _draftPosition$from !== void 0 ? _draftPosition$from : 0) + 1;
|
|
388
386
|
if (draftPosition !== null && posToCheck === pos) {
|
|
389
387
|
setShouldApplyDraftAnnotation(true);
|
|
390
388
|
setPosition(posToCheck);
|
|
@@ -392,7 +390,7 @@ const MediaWithDraftAnnotation = props => {
|
|
|
392
390
|
setShouldApplyDraftAnnotation(false);
|
|
393
391
|
setPosition(undefined);
|
|
394
392
|
}
|
|
395
|
-
}, [draftPosition, pos, shouldApplyDraftAnnotation
|
|
393
|
+
}, [draftPosition, pos, shouldApplyDraftAnnotation]);
|
|
396
394
|
const applyDraftAnnotation = props.allowAnnotationsDraftMode && shouldApplyDraftAnnotation && position !== undefined;
|
|
397
395
|
const dataAttributesWithDraftAnnotation = useMemo(() => applyDraftAnnotation ? {
|
|
398
396
|
...dataAttributes,
|