@atlaskit/renderer 124.10.1 → 124.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/react/nodes/bodiedExtension.js +10 -22
- package/dist/cjs/render-document.js +1 -4
- package/dist/cjs/ui/Renderer/ErrorBoundary.js +2 -1
- package/dist/cjs/ui/Renderer/analytics-utils.js +42 -1
- package/dist/cjs/ui/Renderer/index.js +25 -16
- package/dist/cjs/ui/annotations/selection/mounter.js +3 -0
- package/dist/es2019/react/nodes/bodiedExtension.js +6 -19
- package/dist/es2019/render-document.js +1 -4
- package/dist/es2019/ui/Renderer/ErrorBoundary.js +2 -0
- package/dist/es2019/ui/Renderer/analytics-utils.js +39 -0
- package/dist/es2019/ui/Renderer/index.js +26 -17
- package/dist/es2019/ui/annotations/selection/mounter.js +3 -0
- package/dist/esm/react/nodes/bodiedExtension.js +10 -22
- package/dist/esm/render-document.js +1 -4
- package/dist/esm/ui/Renderer/ErrorBoundary.js +2 -0
- package/dist/esm/ui/Renderer/analytics-utils.js +41 -0
- package/dist/esm/ui/Renderer/index.js +26 -17
- package/dist/esm/ui/annotations/selection/mounter.js +3 -0
- package/dist/types/analytics/events.d.ts +11 -1
- package/dist/types/ui/Renderer/analytics-utils.d.ts +1 -0
- package/dist/types-ts4.5/analytics/events.d.ts +11 -1
- package/dist/types-ts4.5/ui/Renderer/analytics-utils.d.ts +1 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 124.10.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4660917b9e6b9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4660917b9e6b9) -
|
|
8
|
+
Cleaned platform_editor_nested_table_extension_comment_fix FG.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 124.10.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`ca454ed251e1e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ca454ed251e1e) -
|
|
16
|
+
Add table height analytics
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 124.10.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -16,26 +16,7 @@ var _enums = require("../../analytics/enums");
|
|
|
16
16
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
17
17
|
var _annotations = require("../../ui/annotations");
|
|
18
18
|
var _ValidationContext = require("../../ui/Renderer/ValidationContext");
|
|
19
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
21
|
-
var ValidationContextWrapper = function ValidationContextWrapper(_ref) {
|
|
22
|
-
var children = _ref.children;
|
|
23
|
-
// We override validation of nested tables in nested renderers as invalid ADF (but valid Prosemirror)
|
|
24
|
-
// may have been introduced in the parent renderer's render and subsequent transformations.
|
|
25
|
-
// For example - nested tables which are transformed from an extension node in ADF
|
|
26
|
-
// to native Prosemirror nested table nodes in and this is invalid ADF.
|
|
27
|
-
var validationContextValue = (0, _react.useMemo)(function () {
|
|
28
|
-
return {
|
|
29
|
-
allowNestedTables: true
|
|
30
|
-
};
|
|
31
|
-
}, []);
|
|
32
|
-
if (!(0, _platformFeatureFlags.fg)('platform_editor_nested_table_extension_comment_fix')) {
|
|
33
|
-
return children;
|
|
34
|
-
}
|
|
35
|
-
return /*#__PURE__*/_react.default.createElement(_ValidationContext.ValidationContextProvider, {
|
|
36
|
-
value: validationContextValue
|
|
37
|
-
}, children);
|
|
38
|
-
};
|
|
39
20
|
var BodiedExtension = function BodiedExtension(props) {
|
|
40
21
|
var children = props.children,
|
|
41
22
|
_props$layout = props.layout,
|
|
@@ -55,6 +36,11 @@ var BodiedExtension = function BodiedExtension(props) {
|
|
|
55
36
|
.map(function (child) {
|
|
56
37
|
return /*#__PURE__*/_react.default.isValidElement(child) ? child.props.nodeType === 'table' : false;
|
|
57
38
|
}).every(Boolean);
|
|
39
|
+
var validationContextValue = (0, _react.useMemo)(function () {
|
|
40
|
+
return {
|
|
41
|
+
allowNestedTables: true
|
|
42
|
+
};
|
|
43
|
+
}, []);
|
|
58
44
|
return /*#__PURE__*/_react.default.createElement(_ErrorBoundary.ErrorBoundary, {
|
|
59
45
|
component: _enums.ACTION_SUBJECT.RENDERER,
|
|
60
46
|
componentId: _analytics.ACTION_SUBJECT_ID.EXTENSION_BODIED,
|
|
@@ -64,13 +50,15 @@ var BodiedExtension = function BodiedExtension(props) {
|
|
|
64
50
|
value: {
|
|
65
51
|
startPos: props.startPos + 1
|
|
66
52
|
}
|
|
67
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
53
|
+
}, /*#__PURE__*/_react.default.createElement(_ValidationContext.ValidationContextProvider, {
|
|
54
|
+
value: validationContextValue
|
|
55
|
+
}, /*#__PURE__*/_react.default.createElement(_ExtensionRenderer.default
|
|
68
56
|
// Ignored via go/ees005
|
|
69
57
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
70
58
|
, (0, _extends2.default)({}, props, {
|
|
71
59
|
type: "bodiedExtension"
|
|
72
|
-
}), function (
|
|
73
|
-
var result =
|
|
60
|
+
}), function (_ref) {
|
|
61
|
+
var result = _ref.result;
|
|
74
62
|
try {
|
|
75
63
|
if (result && /*#__PURE__*/_react.default.isValidElement(result)) {
|
|
76
64
|
// Return the content directly if it's a valid JSX.Element
|
|
@@ -70,10 +70,7 @@ var _validation = function _validation(doc, schema, adfStage, useSpecBasedValida
|
|
|
70
70
|
|
|
71
71
|
// Convert nested-table extensions into nested tables
|
|
72
72
|
try {
|
|
73
|
-
var _transformNestedTable = (0, _transforms.transformNestedTablesIncomingDocument)(result,
|
|
74
|
-
environment: 'renderer',
|
|
75
|
-
disableNestedRendererTreatment: (0, _platformFeatureFlags.fg)('platform_editor_nested_table_extension_comment_fix')
|
|
76
|
-
}),
|
|
73
|
+
var _transformNestedTable = (0, _transforms.transformNestedTablesIncomingDocument)(result),
|
|
77
74
|
_transformedAdf = _transformNestedTable.transformedAdf,
|
|
78
75
|
_isTransformed = _transformNestedTable.isTransformed;
|
|
79
76
|
if (_isTransformed) {
|
|
@@ -18,7 +18,7 @@ var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
|
18
18
|
var _events = require("../../analytics/events");
|
|
19
19
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
20
20
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
21
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
21
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
22
22
|
// Ignored via go/ees005
|
|
23
23
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
24
24
|
var ErrorBoundary = exports.ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
@@ -111,6 +111,7 @@ var ErrorBoundary = exports.ErrorBoundary = /*#__PURE__*/function (_React$Compon
|
|
|
111
111
|
key: "render",
|
|
112
112
|
value: function render() {
|
|
113
113
|
if (this.state.domError) {
|
|
114
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
114
115
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
115
116
|
key: (0, _uuid.default)()
|
|
116
117
|
}, this.props.children);
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getWidthInfoPayload = void 0;
|
|
7
|
+
exports.getWidthInfoPayload = exports.getHeightInfoPayload = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
10
|
var _analytics2 = require("@atlaskit/editor-common/utils/analytics");
|
|
@@ -47,4 +47,45 @@ var getWidthInfoPayload = exports.getWidthInfoPayload = function getWidthInfoPay
|
|
|
47
47
|
},
|
|
48
48
|
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
49
49
|
};
|
|
50
|
+
};
|
|
51
|
+
var getHeightInfoPayload = exports.getHeightInfoPayload = function getHeightInfoPayload(renderer) {
|
|
52
|
+
var tablesInfo = [];
|
|
53
|
+
var tableWrappers = renderer.querySelectorAll('.pm-table-wrapper');
|
|
54
|
+
|
|
55
|
+
// only send the event if there are tables on the page
|
|
56
|
+
if (tableWrappers.length === 0) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
tableWrappers.forEach(function (tableWrapper) {
|
|
60
|
+
var table = tableWrapper.querySelector(':scope > table');
|
|
61
|
+
if (table) {
|
|
62
|
+
var isNestedTable = Boolean(table.closest('td, th'));
|
|
63
|
+
tablesInfo.push({
|
|
64
|
+
tableHeight: table.scrollHeight,
|
|
65
|
+
isNestedTable: isNestedTable
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
var maxTableHeight = Math.max.apply(Math, (0, _toConsumableArray2.default)(tablesInfo.map(function (table) {
|
|
70
|
+
return table.tableHeight;
|
|
71
|
+
})));
|
|
72
|
+
|
|
73
|
+
/** NOTE: Renderer is not scrollable, so this height represents the height of the content */
|
|
74
|
+
var rendererClientHeight = renderer.clientHeight;
|
|
75
|
+
var viewportHeight = window.innerHeight;
|
|
76
|
+
if (!viewportHeight) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
action: _analytics.TABLE_ACTION.TABLE_RENDERER_HEIGHT_INFO,
|
|
81
|
+
actionSubject: _analytics.ACTION_SUBJECT.TABLE,
|
|
82
|
+
attributes: {
|
|
83
|
+
viewportHeight: viewportHeight,
|
|
84
|
+
rendererHeight: rendererClientHeight,
|
|
85
|
+
maxTableHeight: maxTableHeight,
|
|
86
|
+
maxTableToViewportHeightRatio: maxTableHeight / viewportHeight,
|
|
87
|
+
tableHeightInfo: tablesInfo
|
|
88
|
+
},
|
|
89
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
90
|
+
};
|
|
50
91
|
};
|
|
@@ -62,13 +62,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
62
62
|
* @jsx jsx
|
|
63
63
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
64
64
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
65
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
65
66
|
var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
66
67
|
var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
67
68
|
|
|
68
69
|
// we want to calculate all the table widths (which causes reflows) after the renderer has finished loading to mitigate performance impact
|
|
69
|
-
var
|
|
70
|
+
var TABLE_INFO_TIMEOUT = 10000;
|
|
70
71
|
var packageName = "@atlaskit/renderer";
|
|
71
|
-
var packageVersion = "
|
|
72
|
+
var packageVersion = "0.0.0-development";
|
|
72
73
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
73
74
|
containerName: 'ak-renderer-wrapper',
|
|
74
75
|
containerType: 'inline-size'
|
|
@@ -274,6 +275,7 @@ var RendererFunctionalComponent = exports.RendererFunctionalComponent = function
|
|
|
274
275
|
}, deriveSerializerProps, props);
|
|
275
276
|
var localRef = (0, _react.useRef)(null);
|
|
276
277
|
var editorRef = props.innerRef || localRef;
|
|
278
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
277
279
|
var id = (0, _react.useMemo)(function () {
|
|
278
280
|
return (0, _v.default)();
|
|
279
281
|
}, []);
|
|
@@ -326,9 +328,9 @@ var RendererFunctionalComponent = exports.RendererFunctionalComponent = function
|
|
|
326
328
|
analyticsEventSeverityTracking = props.analyticsEventSeverityTracking;
|
|
327
329
|
(0, _react.useEffect)(function () {
|
|
328
330
|
var rafID;
|
|
329
|
-
var
|
|
330
|
-
var
|
|
331
|
-
var
|
|
331
|
+
var heightWidthAnalyticsSetTimeoutID;
|
|
332
|
+
var heightWidthAnalyticsRicID;
|
|
333
|
+
var heightWidthAnalyticsRafID;
|
|
332
334
|
var handleAnalytics = function handleAnalytics() {
|
|
333
335
|
_fireAnalyticsEvent({
|
|
334
336
|
action: _analytics.ACTION.STARTED,
|
|
@@ -369,8 +371,8 @@ var RendererFunctionalComponent = exports.RendererFunctionalComponent = function
|
|
|
369
371
|
anchorLinkAnalytics();
|
|
370
372
|
});
|
|
371
373
|
if ((0, _expValEquals.expValEquals)('platform_editor_editor_width_analytics', 'isEnabled', true)) {
|
|
372
|
-
// send statistics about the widths of the tables on the page for alerting
|
|
373
|
-
|
|
374
|
+
// send statistics about the heights/widths of the tables on the page for alerting
|
|
375
|
+
heightWidthAnalyticsSetTimeoutID = setTimeout(function () {
|
|
374
376
|
var requestIdleCallbackFn = function requestIdleCallbackFn() {
|
|
375
377
|
var _props$innerRef;
|
|
376
378
|
var renderer = (_props$innerRef = props.innerRef) === null || _props$innerRef === void 0 || (_props$innerRef = _props$innerRef.current) === null || _props$innerRef === void 0 ? void 0 : _props$innerRef.querySelector('.ak-renderer-document');
|
|
@@ -379,15 +381,21 @@ var RendererFunctionalComponent = exports.RendererFunctionalComponent = function
|
|
|
379
381
|
if (payload) {
|
|
380
382
|
_fireAnalyticsEvent(payload);
|
|
381
383
|
}
|
|
384
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_table_height_analytics_event')) {
|
|
385
|
+
var payloadHeight = (0, _analyticsUtils.getHeightInfoPayload)(renderer);
|
|
386
|
+
if (payloadHeight) {
|
|
387
|
+
_fireAnalyticsEvent(payloadHeight);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
382
390
|
}
|
|
383
391
|
};
|
|
384
392
|
if (window && typeof window.requestIdleCallback === 'function') {
|
|
385
|
-
|
|
393
|
+
heightWidthAnalyticsRicID = window.requestIdleCallback(requestIdleCallbackFn);
|
|
386
394
|
} else if (window && typeof window.requestAnimationFrame === 'function') {
|
|
387
395
|
// requestIdleCallback is not supported in safari, fallback to requestAnimationFrame
|
|
388
|
-
|
|
396
|
+
heightWidthAnalyticsRafID = window.requestAnimationFrame(requestIdleCallbackFn);
|
|
389
397
|
}
|
|
390
|
-
},
|
|
398
|
+
}, TABLE_INFO_TIMEOUT);
|
|
391
399
|
}
|
|
392
400
|
};
|
|
393
401
|
handleAnalytics();
|
|
@@ -395,14 +403,14 @@ var RendererFunctionalComponent = exports.RendererFunctionalComponent = function
|
|
|
395
403
|
if (rafID) {
|
|
396
404
|
window.cancelAnimationFrame(rafID);
|
|
397
405
|
}
|
|
398
|
-
if (
|
|
399
|
-
window.clearTimeout(
|
|
406
|
+
if (heightWidthAnalyticsSetTimeoutID) {
|
|
407
|
+
window.clearTimeout(heightWidthAnalyticsSetTimeoutID);
|
|
400
408
|
}
|
|
401
|
-
if (
|
|
402
|
-
window.cancelAnimationFrame(
|
|
409
|
+
if (heightWidthAnalyticsRafID) {
|
|
410
|
+
window.cancelAnimationFrame(heightWidthAnalyticsRafID);
|
|
403
411
|
}
|
|
404
|
-
if (
|
|
405
|
-
window.cancelIdleCallback(
|
|
412
|
+
if (heightWidthAnalyticsRicID) {
|
|
413
|
+
window.cancelIdleCallback(heightWidthAnalyticsRicID);
|
|
406
414
|
}
|
|
407
415
|
|
|
408
416
|
// if this is the ProviderFactory which was created in constructor
|
|
@@ -553,6 +561,7 @@ var RendererWithAnalytics = exports.RendererWithAnalytics = /*#__PURE__*/_react.
|
|
|
553
561
|
packageName: packageName,
|
|
554
562
|
packageVersion: packageVersion,
|
|
555
563
|
componentName: 'renderer',
|
|
564
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
556
565
|
editorSessionId: (0, _v.default)()
|
|
557
566
|
}
|
|
558
567
|
}, (0, _react2.jsx)(_ui.WithCreateAnalyticsEvent, {
|
|
@@ -18,6 +18,8 @@ var _RendererActionsContext = require("../../RendererActionsContext");
|
|
|
18
18
|
var _AnnotationManagerContext = require("../contexts/AnnotationManagerContext");
|
|
19
19
|
var _AnnotationRangeContext = require("../contexts/AnnotationRangeContext");
|
|
20
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
21
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
22
|
+
|
|
21
23
|
var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#__PURE__*/_react.default.memo(function (props) {
|
|
22
24
|
var Component = props.component,
|
|
23
25
|
range = props.range,
|
|
@@ -203,6 +205,7 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
203
205
|
// if there is a draft in progress, we ignore it and start a new draft
|
|
204
206
|
// this is because clearing the draft will remove the mark node from the DOM, which will cause the selection range to be invalid
|
|
205
207
|
|
|
208
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
206
209
|
var id = (0, _v.default)();
|
|
207
210
|
var result = applyDraftModeCallback({
|
|
208
211
|
annotationId: id,
|
|
@@ -8,24 +8,6 @@ import { ACTION_SUBJECT } from '../../analytics/enums';
|
|
|
8
8
|
import { ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
9
9
|
import { AnnotationsPositionContext } from '../../ui/annotations';
|
|
10
10
|
import { ValidationContextProvider } from '../../ui/Renderer/ValidationContext';
|
|
11
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
-
const ValidationContextWrapper = ({
|
|
13
|
-
children
|
|
14
|
-
}) => {
|
|
15
|
-
// We override validation of nested tables in nested renderers as invalid ADF (but valid Prosemirror)
|
|
16
|
-
// may have been introduced in the parent renderer's render and subsequent transformations.
|
|
17
|
-
// For example - nested tables which are transformed from an extension node in ADF
|
|
18
|
-
// to native Prosemirror nested table nodes in and this is invalid ADF.
|
|
19
|
-
const validationContextValue = useMemo(() => ({
|
|
20
|
-
allowNestedTables: true
|
|
21
|
-
}), []);
|
|
22
|
-
if (!fg('platform_editor_nested_table_extension_comment_fix')) {
|
|
23
|
-
return children;
|
|
24
|
-
}
|
|
25
|
-
return /*#__PURE__*/React.createElement(ValidationContextProvider, {
|
|
26
|
-
value: validationContextValue
|
|
27
|
-
}, children);
|
|
28
|
-
};
|
|
29
11
|
const BodiedExtension = props => {
|
|
30
12
|
const {
|
|
31
13
|
children,
|
|
@@ -44,6 +26,9 @@ const BodiedExtension = props => {
|
|
|
44
26
|
// Ignored via go/ees005
|
|
45
27
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
28
|
.map(child => /*#__PURE__*/React.isValidElement(child) ? child.props.nodeType === 'table' : false).every(Boolean);
|
|
29
|
+
const validationContextValue = useMemo(() => ({
|
|
30
|
+
allowNestedTables: true
|
|
31
|
+
}), []);
|
|
47
32
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
48
33
|
component: ACTION_SUBJECT.RENDERER,
|
|
49
34
|
componentId: ACTION_SUBJECT_ID.EXTENSION_BODIED,
|
|
@@ -53,7 +38,9 @@ const BodiedExtension = props => {
|
|
|
53
38
|
value: {
|
|
54
39
|
startPos: props.startPos + 1
|
|
55
40
|
}
|
|
56
|
-
}, /*#__PURE__*/React.createElement(
|
|
41
|
+
}, /*#__PURE__*/React.createElement(ValidationContextProvider, {
|
|
42
|
+
value: validationContextValue
|
|
43
|
+
}, /*#__PURE__*/React.createElement(ExtensionRenderer
|
|
57
44
|
// Ignored via go/ees005
|
|
58
45
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
59
46
|
, _extends({}, props, {
|
|
@@ -66,10 +66,7 @@ const _validation = (doc, schema, adfStage, useSpecBasedValidator, dispatchAnaly
|
|
|
66
66
|
const {
|
|
67
67
|
transformedAdf,
|
|
68
68
|
isTransformed
|
|
69
|
-
} = transformNestedTablesIncomingDocument(result
|
|
70
|
-
environment: 'renderer',
|
|
71
|
-
disableNestedRendererTreatment: fg('platform_editor_nested_table_extension_comment_fix')
|
|
72
|
-
});
|
|
69
|
+
} = transformNestedTablesIncomingDocument(result);
|
|
73
70
|
if (isTransformed) {
|
|
74
71
|
dispatchAnalyticsEvent === null || dispatchAnalyticsEvent === void 0 ? void 0 : dispatchAnalyticsEvent({
|
|
75
72
|
action: ACTION.NESTED_TABLE_TRANSFORMED,
|
|
@@ -4,6 +4,7 @@ import { ACTION, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
|
4
4
|
import { FabricChannel } from '@atlaskit/analytics-listeners/types';
|
|
5
5
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
6
6
|
import { PLATFORM } from '../../analytics/events';
|
|
7
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
7
8
|
import uuid from 'uuid';
|
|
8
9
|
// Ignored via go/ees005
|
|
9
10
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -79,6 +80,7 @@ export class ErrorBoundary extends React.Component {
|
|
|
79
80
|
}
|
|
80
81
|
render() {
|
|
81
82
|
if (this.state.domError) {
|
|
83
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
82
84
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
83
85
|
key: uuid()
|
|
84
86
|
}, this.props.children);
|
|
@@ -35,4 +35,43 @@ export const getWidthInfoPayload = renderer => {
|
|
|
35
35
|
},
|
|
36
36
|
eventType: EVENT_TYPE.OPERATIONAL
|
|
37
37
|
};
|
|
38
|
+
};
|
|
39
|
+
export const getHeightInfoPayload = renderer => {
|
|
40
|
+
const tablesInfo = [];
|
|
41
|
+
const tableWrappers = renderer.querySelectorAll('.pm-table-wrapper');
|
|
42
|
+
|
|
43
|
+
// only send the event if there are tables on the page
|
|
44
|
+
if (tableWrappers.length === 0) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
tableWrappers.forEach(tableWrapper => {
|
|
48
|
+
const table = tableWrapper.querySelector(':scope > table');
|
|
49
|
+
if (table) {
|
|
50
|
+
const isNestedTable = Boolean(table.closest('td, th'));
|
|
51
|
+
tablesInfo.push({
|
|
52
|
+
tableHeight: table.scrollHeight,
|
|
53
|
+
isNestedTable
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const maxTableHeight = Math.max(...tablesInfo.map(table => table.tableHeight));
|
|
58
|
+
|
|
59
|
+
/** NOTE: Renderer is not scrollable, so this height represents the height of the content */
|
|
60
|
+
const rendererClientHeight = renderer.clientHeight;
|
|
61
|
+
const viewportHeight = window.innerHeight;
|
|
62
|
+
if (!viewportHeight) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
action: TABLE_ACTION.TABLE_RENDERER_HEIGHT_INFO,
|
|
67
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
68
|
+
attributes: {
|
|
69
|
+
viewportHeight,
|
|
70
|
+
rendererHeight: rendererClientHeight,
|
|
71
|
+
maxTableHeight,
|
|
72
|
+
maxTableToViewportHeightRatio: maxTableHeight / viewportHeight,
|
|
73
|
+
tableHeightInfo: tablesInfo
|
|
74
|
+
},
|
|
75
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
76
|
+
};
|
|
38
77
|
};
|
|
@@ -21,6 +21,7 @@ import { FabricChannel } from '@atlaskit/analytics-listeners/types';
|
|
|
21
21
|
import { FabricEditorAnalyticsContext } from '@atlaskit/analytics-namespaced-context';
|
|
22
22
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
23
23
|
import { normalizeFeatureFlags } from '@atlaskit/editor-common/normalize-feature-flags';
|
|
24
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
24
25
|
import uuid from 'uuid/v4';
|
|
25
26
|
import { ReactSerializer, renderDocument } from '../../';
|
|
26
27
|
import AnalyticsContext from '../../analytics/analyticsContext';
|
|
@@ -47,14 +48,14 @@ import { useMemoFromPropsDerivative } from './useMemoFromPropsDerivative';
|
|
|
47
48
|
import { PortalContext } from './PortalContext';
|
|
48
49
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
49
50
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
50
|
-
import { getWidthInfoPayload } from './analytics-utils';
|
|
51
|
+
import { getHeightInfoPayload, getWidthInfoPayload } from './analytics-utils';
|
|
51
52
|
export const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
52
53
|
export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
53
54
|
|
|
54
55
|
// we want to calculate all the table widths (which causes reflows) after the renderer has finished loading to mitigate performance impact
|
|
55
|
-
const
|
|
56
|
+
const TABLE_INFO_TIMEOUT = 10000;
|
|
56
57
|
const packageName = "@atlaskit/renderer";
|
|
57
|
-
const packageVersion = "
|
|
58
|
+
const packageVersion = "0.0.0-development";
|
|
58
59
|
const setAsQueryContainerStyles = css({
|
|
59
60
|
containerName: 'ak-renderer-wrapper',
|
|
60
61
|
containerType: 'inline-size'
|
|
@@ -268,6 +269,7 @@ export const RendererFunctionalComponent = props => {
|
|
|
268
269
|
}, deriveSerializerProps, props);
|
|
269
270
|
const localRef = useRef(null);
|
|
270
271
|
const editorRef = props.innerRef || localRef;
|
|
272
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
271
273
|
const id = useMemo(() => uuid(), []);
|
|
272
274
|
const renderedMeasurementDistortedDurationMonitor = useMemo(() => getDistortedDurationMonitor(), []);
|
|
273
275
|
|
|
@@ -318,9 +320,9 @@ export const RendererFunctionalComponent = props => {
|
|
|
318
320
|
} = props;
|
|
319
321
|
useEffect(() => {
|
|
320
322
|
let rafID;
|
|
321
|
-
let
|
|
322
|
-
let
|
|
323
|
-
let
|
|
323
|
+
let heightWidthAnalyticsSetTimeoutID;
|
|
324
|
+
let heightWidthAnalyticsRicID;
|
|
325
|
+
let heightWidthAnalyticsRafID;
|
|
324
326
|
const handleAnalytics = () => {
|
|
325
327
|
fireAnalyticsEvent({
|
|
326
328
|
action: ACTION.STARTED,
|
|
@@ -361,8 +363,8 @@ export const RendererFunctionalComponent = props => {
|
|
|
361
363
|
anchorLinkAnalytics();
|
|
362
364
|
});
|
|
363
365
|
if (expValEquals('platform_editor_editor_width_analytics', 'isEnabled', true)) {
|
|
364
|
-
// send statistics about the widths of the tables on the page for alerting
|
|
365
|
-
|
|
366
|
+
// send statistics about the heights/widths of the tables on the page for alerting
|
|
367
|
+
heightWidthAnalyticsSetTimeoutID = setTimeout(() => {
|
|
366
368
|
const requestIdleCallbackFn = () => {
|
|
367
369
|
var _props$innerRef, _props$innerRef$curre;
|
|
368
370
|
const renderer = (_props$innerRef = props.innerRef) === null || _props$innerRef === void 0 ? void 0 : (_props$innerRef$curre = _props$innerRef.current) === null || _props$innerRef$curre === void 0 ? void 0 : _props$innerRef$curre.querySelector('.ak-renderer-document');
|
|
@@ -371,15 +373,21 @@ export const RendererFunctionalComponent = props => {
|
|
|
371
373
|
if (payload) {
|
|
372
374
|
fireAnalyticsEvent(payload);
|
|
373
375
|
}
|
|
376
|
+
if (fg('platform_editor_table_height_analytics_event')) {
|
|
377
|
+
const payloadHeight = getHeightInfoPayload(renderer);
|
|
378
|
+
if (payloadHeight) {
|
|
379
|
+
fireAnalyticsEvent(payloadHeight);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
374
382
|
}
|
|
375
383
|
};
|
|
376
384
|
if (window && typeof window.requestIdleCallback === 'function') {
|
|
377
|
-
|
|
385
|
+
heightWidthAnalyticsRicID = window.requestIdleCallback(requestIdleCallbackFn);
|
|
378
386
|
} else if (window && typeof window.requestAnimationFrame === 'function') {
|
|
379
387
|
// requestIdleCallback is not supported in safari, fallback to requestAnimationFrame
|
|
380
|
-
|
|
388
|
+
heightWidthAnalyticsRafID = window.requestAnimationFrame(requestIdleCallbackFn);
|
|
381
389
|
}
|
|
382
|
-
},
|
|
390
|
+
}, TABLE_INFO_TIMEOUT);
|
|
383
391
|
}
|
|
384
392
|
};
|
|
385
393
|
handleAnalytics();
|
|
@@ -387,14 +395,14 @@ export const RendererFunctionalComponent = props => {
|
|
|
387
395
|
if (rafID) {
|
|
388
396
|
window.cancelAnimationFrame(rafID);
|
|
389
397
|
}
|
|
390
|
-
if (
|
|
391
|
-
window.clearTimeout(
|
|
398
|
+
if (heightWidthAnalyticsSetTimeoutID) {
|
|
399
|
+
window.clearTimeout(heightWidthAnalyticsSetTimeoutID);
|
|
392
400
|
}
|
|
393
|
-
if (
|
|
394
|
-
window.cancelAnimationFrame(
|
|
401
|
+
if (heightWidthAnalyticsRafID) {
|
|
402
|
+
window.cancelAnimationFrame(heightWidthAnalyticsRafID);
|
|
395
403
|
}
|
|
396
|
-
if (
|
|
397
|
-
window.cancelIdleCallback(
|
|
404
|
+
if (heightWidthAnalyticsRicID) {
|
|
405
|
+
window.cancelIdleCallback(heightWidthAnalyticsRicID);
|
|
398
406
|
}
|
|
399
407
|
|
|
400
408
|
// if this is the ProviderFactory which was created in constructor
|
|
@@ -540,6 +548,7 @@ export const RendererWithAnalytics = /*#__PURE__*/React.memo(props => jsx(Fabric
|
|
|
540
548
|
packageName,
|
|
541
549
|
packageVersion,
|
|
542
550
|
componentName: 'renderer',
|
|
551
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
543
552
|
editorSessionId: uuid()
|
|
544
553
|
}
|
|
545
554
|
}, jsx(WithCreateAnalyticsEvent, {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useContext, useMemo, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
2
4
|
import uuid from 'uuid/v4';
|
|
3
5
|
import { AnnotationTypes, AnnotationMarkStates } from '@atlaskit/adf-schema';
|
|
4
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -200,6 +202,7 @@ export const SelectionInlineCommentMounter = /*#__PURE__*/React.memo(props => {
|
|
|
200
202
|
// if there is a draft in progress, we ignore it and start a new draft
|
|
201
203
|
// this is because clearing the draft will remove the mark node from the DOM, which will cause the selection range to be invalid
|
|
202
204
|
|
|
205
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
203
206
|
const id = uuid();
|
|
204
207
|
const result = applyDraftModeCallback({
|
|
205
208
|
annotationId: id,
|
|
@@ -8,25 +8,6 @@ import { ACTION_SUBJECT } from '../../analytics/enums';
|
|
|
8
8
|
import { ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
9
9
|
import { AnnotationsPositionContext } from '../../ui/annotations';
|
|
10
10
|
import { ValidationContextProvider } from '../../ui/Renderer/ValidationContext';
|
|
11
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
-
var ValidationContextWrapper = function ValidationContextWrapper(_ref) {
|
|
13
|
-
var children = _ref.children;
|
|
14
|
-
// We override validation of nested tables in nested renderers as invalid ADF (but valid Prosemirror)
|
|
15
|
-
// may have been introduced in the parent renderer's render and subsequent transformations.
|
|
16
|
-
// For example - nested tables which are transformed from an extension node in ADF
|
|
17
|
-
// to native Prosemirror nested table nodes in and this is invalid ADF.
|
|
18
|
-
var validationContextValue = useMemo(function () {
|
|
19
|
-
return {
|
|
20
|
-
allowNestedTables: true
|
|
21
|
-
};
|
|
22
|
-
}, []);
|
|
23
|
-
if (!fg('platform_editor_nested_table_extension_comment_fix')) {
|
|
24
|
-
return children;
|
|
25
|
-
}
|
|
26
|
-
return /*#__PURE__*/React.createElement(ValidationContextProvider, {
|
|
27
|
-
value: validationContextValue
|
|
28
|
-
}, children);
|
|
29
|
-
};
|
|
30
11
|
var BodiedExtension = function BodiedExtension(props) {
|
|
31
12
|
var children = props.children,
|
|
32
13
|
_props$layout = props.layout,
|
|
@@ -46,6 +27,11 @@ var BodiedExtension = function BodiedExtension(props) {
|
|
|
46
27
|
.map(function (child) {
|
|
47
28
|
return /*#__PURE__*/React.isValidElement(child) ? child.props.nodeType === 'table' : false;
|
|
48
29
|
}).every(Boolean);
|
|
30
|
+
var validationContextValue = useMemo(function () {
|
|
31
|
+
return {
|
|
32
|
+
allowNestedTables: true
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
49
35
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
50
36
|
component: ACTION_SUBJECT.RENDERER,
|
|
51
37
|
componentId: ACTION_SUBJECT_ID.EXTENSION_BODIED,
|
|
@@ -55,13 +41,15 @@ var BodiedExtension = function BodiedExtension(props) {
|
|
|
55
41
|
value: {
|
|
56
42
|
startPos: props.startPos + 1
|
|
57
43
|
}
|
|
58
|
-
}, /*#__PURE__*/React.createElement(
|
|
44
|
+
}, /*#__PURE__*/React.createElement(ValidationContextProvider, {
|
|
45
|
+
value: validationContextValue
|
|
46
|
+
}, /*#__PURE__*/React.createElement(ExtensionRenderer
|
|
59
47
|
// Ignored via go/ees005
|
|
60
48
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
61
49
|
, _extends({}, props, {
|
|
62
50
|
type: "bodiedExtension"
|
|
63
|
-
}), function (
|
|
64
|
-
var result =
|
|
51
|
+
}), function (_ref) {
|
|
52
|
+
var result = _ref.result;
|
|
65
53
|
try {
|
|
66
54
|
if (result && /*#__PURE__*/React.isValidElement(result)) {
|
|
67
55
|
// Return the content directly if it's a valid JSX.Element
|
|
@@ -63,10 +63,7 @@ var _validation = function _validation(doc, schema, adfStage, useSpecBasedValida
|
|
|
63
63
|
|
|
64
64
|
// Convert nested-table extensions into nested tables
|
|
65
65
|
try {
|
|
66
|
-
var _transformNestedTable = transformNestedTablesIncomingDocument(result,
|
|
67
|
-
environment: 'renderer',
|
|
68
|
-
disableNestedRendererTreatment: fg('platform_editor_nested_table_extension_comment_fix')
|
|
69
|
-
}),
|
|
66
|
+
var _transformNestedTable = transformNestedTablesIncomingDocument(result),
|
|
70
67
|
_transformedAdf = _transformNestedTable.transformedAdf,
|
|
71
68
|
_isTransformed = _transformNestedTable.isTransformed;
|
|
72
69
|
if (_isTransformed) {
|
|
@@ -11,6 +11,7 @@ import { ACTION, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
|
11
11
|
import { FabricChannel } from '@atlaskit/analytics-listeners/types';
|
|
12
12
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
13
13
|
import { PLATFORM } from '../../analytics/events';
|
|
14
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
14
15
|
import uuid from 'uuid';
|
|
15
16
|
// Ignored via go/ees005
|
|
16
17
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -104,6 +105,7 @@ export var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
|
104
105
|
key: "render",
|
|
105
106
|
value: function render() {
|
|
106
107
|
if (this.state.domError) {
|
|
108
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
107
109
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
108
110
|
key: uuid()
|
|
109
111
|
}, this.props.children);
|
|
@@ -40,4 +40,45 @@ export var getWidthInfoPayload = function getWidthInfoPayload(renderer) {
|
|
|
40
40
|
},
|
|
41
41
|
eventType: EVENT_TYPE.OPERATIONAL
|
|
42
42
|
};
|
|
43
|
+
};
|
|
44
|
+
export var getHeightInfoPayload = function getHeightInfoPayload(renderer) {
|
|
45
|
+
var tablesInfo = [];
|
|
46
|
+
var tableWrappers = renderer.querySelectorAll('.pm-table-wrapper');
|
|
47
|
+
|
|
48
|
+
// only send the event if there are tables on the page
|
|
49
|
+
if (tableWrappers.length === 0) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
tableWrappers.forEach(function (tableWrapper) {
|
|
53
|
+
var table = tableWrapper.querySelector(':scope > table');
|
|
54
|
+
if (table) {
|
|
55
|
+
var isNestedTable = Boolean(table.closest('td, th'));
|
|
56
|
+
tablesInfo.push({
|
|
57
|
+
tableHeight: table.scrollHeight,
|
|
58
|
+
isNestedTable: isNestedTable
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
var maxTableHeight = Math.max.apply(Math, _toConsumableArray(tablesInfo.map(function (table) {
|
|
63
|
+
return table.tableHeight;
|
|
64
|
+
})));
|
|
65
|
+
|
|
66
|
+
/** NOTE: Renderer is not scrollable, so this height represents the height of the content */
|
|
67
|
+
var rendererClientHeight = renderer.clientHeight;
|
|
68
|
+
var viewportHeight = window.innerHeight;
|
|
69
|
+
if (!viewportHeight) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
action: TABLE_ACTION.TABLE_RENDERER_HEIGHT_INFO,
|
|
74
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
75
|
+
attributes: {
|
|
76
|
+
viewportHeight: viewportHeight,
|
|
77
|
+
rendererHeight: rendererClientHeight,
|
|
78
|
+
maxTableHeight: maxTableHeight,
|
|
79
|
+
maxTableToViewportHeightRatio: maxTableHeight / viewportHeight,
|
|
80
|
+
tableHeightInfo: tablesInfo
|
|
81
|
+
},
|
|
82
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
83
|
+
};
|
|
43
84
|
};
|
|
@@ -26,6 +26,7 @@ import { FabricChannel } from '@atlaskit/analytics-listeners/types';
|
|
|
26
26
|
import { FabricEditorAnalyticsContext } from '@atlaskit/analytics-namespaced-context';
|
|
27
27
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
28
28
|
import { normalizeFeatureFlags } from '@atlaskit/editor-common/normalize-feature-flags';
|
|
29
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
29
30
|
import uuid from 'uuid/v4';
|
|
30
31
|
import { ReactSerializer, renderDocument } from '../../';
|
|
31
32
|
import AnalyticsContext from '../../analytics/analyticsContext';
|
|
@@ -52,14 +53,14 @@ import { useMemoFromPropsDerivative } from './useMemoFromPropsDerivative';
|
|
|
52
53
|
import { PortalContext } from './PortalContext';
|
|
53
54
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
54
55
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
55
|
-
import { getWidthInfoPayload } from './analytics-utils';
|
|
56
|
+
import { getHeightInfoPayload, getWidthInfoPayload } from './analytics-utils';
|
|
56
57
|
export var NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
57
58
|
export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
58
59
|
|
|
59
60
|
// we want to calculate all the table widths (which causes reflows) after the renderer has finished loading to mitigate performance impact
|
|
60
|
-
var
|
|
61
|
+
var TABLE_INFO_TIMEOUT = 10000;
|
|
61
62
|
var packageName = "@atlaskit/renderer";
|
|
62
|
-
var packageVersion = "
|
|
63
|
+
var packageVersion = "0.0.0-development";
|
|
63
64
|
var setAsQueryContainerStyles = css({
|
|
64
65
|
containerName: 'ak-renderer-wrapper',
|
|
65
66
|
containerType: 'inline-size'
|
|
@@ -265,6 +266,7 @@ export var RendererFunctionalComponent = function RendererFunctionalComponent(pr
|
|
|
265
266
|
}, deriveSerializerProps, props);
|
|
266
267
|
var localRef = useRef(null);
|
|
267
268
|
var editorRef = props.innerRef || localRef;
|
|
269
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
268
270
|
var id = useMemo(function () {
|
|
269
271
|
return uuid();
|
|
270
272
|
}, []);
|
|
@@ -317,9 +319,9 @@ export var RendererFunctionalComponent = function RendererFunctionalComponent(pr
|
|
|
317
319
|
analyticsEventSeverityTracking = props.analyticsEventSeverityTracking;
|
|
318
320
|
useEffect(function () {
|
|
319
321
|
var rafID;
|
|
320
|
-
var
|
|
321
|
-
var
|
|
322
|
-
var
|
|
322
|
+
var heightWidthAnalyticsSetTimeoutID;
|
|
323
|
+
var heightWidthAnalyticsRicID;
|
|
324
|
+
var heightWidthAnalyticsRafID;
|
|
323
325
|
var handleAnalytics = function handleAnalytics() {
|
|
324
326
|
_fireAnalyticsEvent({
|
|
325
327
|
action: ACTION.STARTED,
|
|
@@ -360,8 +362,8 @@ export var RendererFunctionalComponent = function RendererFunctionalComponent(pr
|
|
|
360
362
|
anchorLinkAnalytics();
|
|
361
363
|
});
|
|
362
364
|
if (expValEquals('platform_editor_editor_width_analytics', 'isEnabled', true)) {
|
|
363
|
-
// send statistics about the widths of the tables on the page for alerting
|
|
364
|
-
|
|
365
|
+
// send statistics about the heights/widths of the tables on the page for alerting
|
|
366
|
+
heightWidthAnalyticsSetTimeoutID = setTimeout(function () {
|
|
365
367
|
var requestIdleCallbackFn = function requestIdleCallbackFn() {
|
|
366
368
|
var _props$innerRef;
|
|
367
369
|
var renderer = (_props$innerRef = props.innerRef) === null || _props$innerRef === void 0 || (_props$innerRef = _props$innerRef.current) === null || _props$innerRef === void 0 ? void 0 : _props$innerRef.querySelector('.ak-renderer-document');
|
|
@@ -370,15 +372,21 @@ export var RendererFunctionalComponent = function RendererFunctionalComponent(pr
|
|
|
370
372
|
if (payload) {
|
|
371
373
|
_fireAnalyticsEvent(payload);
|
|
372
374
|
}
|
|
375
|
+
if (fg('platform_editor_table_height_analytics_event')) {
|
|
376
|
+
var payloadHeight = getHeightInfoPayload(renderer);
|
|
377
|
+
if (payloadHeight) {
|
|
378
|
+
_fireAnalyticsEvent(payloadHeight);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
373
381
|
}
|
|
374
382
|
};
|
|
375
383
|
if (window && typeof window.requestIdleCallback === 'function') {
|
|
376
|
-
|
|
384
|
+
heightWidthAnalyticsRicID = window.requestIdleCallback(requestIdleCallbackFn);
|
|
377
385
|
} else if (window && typeof window.requestAnimationFrame === 'function') {
|
|
378
386
|
// requestIdleCallback is not supported in safari, fallback to requestAnimationFrame
|
|
379
|
-
|
|
387
|
+
heightWidthAnalyticsRafID = window.requestAnimationFrame(requestIdleCallbackFn);
|
|
380
388
|
}
|
|
381
|
-
},
|
|
389
|
+
}, TABLE_INFO_TIMEOUT);
|
|
382
390
|
}
|
|
383
391
|
};
|
|
384
392
|
handleAnalytics();
|
|
@@ -386,14 +394,14 @@ export var RendererFunctionalComponent = function RendererFunctionalComponent(pr
|
|
|
386
394
|
if (rafID) {
|
|
387
395
|
window.cancelAnimationFrame(rafID);
|
|
388
396
|
}
|
|
389
|
-
if (
|
|
390
|
-
window.clearTimeout(
|
|
397
|
+
if (heightWidthAnalyticsSetTimeoutID) {
|
|
398
|
+
window.clearTimeout(heightWidthAnalyticsSetTimeoutID);
|
|
391
399
|
}
|
|
392
|
-
if (
|
|
393
|
-
window.cancelAnimationFrame(
|
|
400
|
+
if (heightWidthAnalyticsRafID) {
|
|
401
|
+
window.cancelAnimationFrame(heightWidthAnalyticsRafID);
|
|
394
402
|
}
|
|
395
|
-
if (
|
|
396
|
-
window.cancelIdleCallback(
|
|
403
|
+
if (heightWidthAnalyticsRicID) {
|
|
404
|
+
window.cancelIdleCallback(heightWidthAnalyticsRicID);
|
|
397
405
|
}
|
|
398
406
|
|
|
399
407
|
// if this is the ProviderFactory which was created in constructor
|
|
@@ -544,6 +552,7 @@ export var RendererWithAnalytics = /*#__PURE__*/React.memo(function (props) {
|
|
|
544
552
|
packageName: packageName,
|
|
545
553
|
packageVersion: packageVersion,
|
|
546
554
|
componentName: 'renderer',
|
|
555
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
547
556
|
editorSessionId: uuid()
|
|
548
557
|
}
|
|
549
558
|
}, jsx(WithCreateAnalyticsEvent, {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useContext, useMemo, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
2
4
|
import uuid from 'uuid/v4';
|
|
3
5
|
import { AnnotationTypes, AnnotationMarkStates } from '@atlaskit/adf-schema';
|
|
4
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -194,6 +196,7 @@ export var SelectionInlineCommentMounter = /*#__PURE__*/React.memo(function (pro
|
|
|
194
196
|
// if there is a draft in progress, we ignore it and start a new draft
|
|
195
197
|
// this is because clearing the draft will remove the mark node from the DOM, which will cause the selection range to be invalid
|
|
196
198
|
|
|
199
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
197
200
|
var id = uuid();
|
|
198
201
|
var result = applyDraftModeCallback({
|
|
199
202
|
annotationId: id,
|
|
@@ -96,6 +96,16 @@ type TableWidthInfoAEP = AEP<TABLE_ACTION.TABLE_WIDTH_INFO, ACTION_SUBJECT.TABLE
|
|
|
96
96
|
tableWidth: number;
|
|
97
97
|
}>;
|
|
98
98
|
}, EVENT_TYPE.OPERATIONAL>;
|
|
99
|
+
type TableRendererHeightInfoAEP = AEP<TABLE_ACTION.TABLE_RENDERER_HEIGHT_INFO, ACTION_SUBJECT.TABLE, undefined, {
|
|
100
|
+
maxTableHeight: number;
|
|
101
|
+
maxTableToViewportHeightRatio: number;
|
|
102
|
+
rendererHeight: number;
|
|
103
|
+
tableHeightInfo: Array<{
|
|
104
|
+
isNestedTable: boolean;
|
|
105
|
+
tableHeight: number;
|
|
106
|
+
}>;
|
|
107
|
+
viewportHeight: number;
|
|
108
|
+
}, EVENT_TYPE.OPERATIONAL>;
|
|
99
109
|
type VisitLinkAEP = AEP<ACTION.VISITED, ACTION_SUBJECT.LINK, undefined, {
|
|
100
110
|
mode: MODE.RENDERER;
|
|
101
111
|
platform: PLATFORM.WEB;
|
|
@@ -132,6 +142,6 @@ export type MediaRenderErrorEvent = UIAEP<ACTION.ERRORED, ACTION_SUBJECT.RENDERE
|
|
|
132
142
|
external?: boolean;
|
|
133
143
|
reason: string;
|
|
134
144
|
}>;
|
|
135
|
-
export type AnalyticsEventPayload<T = void> = RendererStartAEP | RendererRenderedAEP | ComponentCrashErrorAEP | RendererUnsupportedContentLevelsTrackingSucceeded | RendererUnsupportedContentLevelsTrackingErrored | RendererSelectAllCaughtAEP | RendererSelectAllEscapedAEP | CodeBlockCopyAEP | CodeBlockWrapAEP | HeadingAnchorLinkButtonAEP | HoverLabelAEP | AnchorLinkAEP | TableSortColumnNotAllowedAEP | TableSortColumnAEP | TableWidthInfoAEP | VisitLinkAEP | VisitMediaLinkAEP | ExpandAEP | UnsupportedContentPayload | UnsupportedContentTooltipPayload | AnnotationAEP | AnnotationDeleteAEP | MediaLnkTransformedAEP | InvalidProsemirrorDocumentErrorAEP | NestedTableTransformedAEP | MediaRenderErrorEvent;
|
|
145
|
+
export type AnalyticsEventPayload<T = void> = RendererStartAEP | RendererRenderedAEP | ComponentCrashErrorAEP | RendererUnsupportedContentLevelsTrackingSucceeded | RendererUnsupportedContentLevelsTrackingErrored | RendererSelectAllCaughtAEP | RendererSelectAllEscapedAEP | CodeBlockCopyAEP | CodeBlockWrapAEP | HeadingAnchorLinkButtonAEP | HoverLabelAEP | AnchorLinkAEP | TableSortColumnNotAllowedAEP | TableSortColumnAEP | TableWidthInfoAEP | TableRendererHeightInfoAEP | VisitLinkAEP | VisitMediaLinkAEP | ExpandAEP | UnsupportedContentPayload | UnsupportedContentTooltipPayload | AnnotationAEP | AnnotationDeleteAEP | MediaLnkTransformedAEP | InvalidProsemirrorDocumentErrorAEP | NestedTableTransformedAEP | MediaRenderErrorEvent;
|
|
136
146
|
export type FireAnalyticsCallback = <T = void>(payload: AnalyticsEventPayload<T>) => void | undefined;
|
|
137
147
|
export {};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { AnalyticsEventPayload } from '../../analytics/events';
|
|
2
2
|
export declare const getWidthInfoPayload: (renderer: HTMLElement) => AnalyticsEventPayload | undefined;
|
|
3
|
+
export declare const getHeightInfoPayload: (renderer: HTMLElement) => AnalyticsEventPayload | undefined;
|
|
@@ -96,6 +96,16 @@ type TableWidthInfoAEP = AEP<TABLE_ACTION.TABLE_WIDTH_INFO, ACTION_SUBJECT.TABLE
|
|
|
96
96
|
tableWidth: number;
|
|
97
97
|
}>;
|
|
98
98
|
}, EVENT_TYPE.OPERATIONAL>;
|
|
99
|
+
type TableRendererHeightInfoAEP = AEP<TABLE_ACTION.TABLE_RENDERER_HEIGHT_INFO, ACTION_SUBJECT.TABLE, undefined, {
|
|
100
|
+
maxTableHeight: number;
|
|
101
|
+
maxTableToViewportHeightRatio: number;
|
|
102
|
+
rendererHeight: number;
|
|
103
|
+
tableHeightInfo: Array<{
|
|
104
|
+
isNestedTable: boolean;
|
|
105
|
+
tableHeight: number;
|
|
106
|
+
}>;
|
|
107
|
+
viewportHeight: number;
|
|
108
|
+
}, EVENT_TYPE.OPERATIONAL>;
|
|
99
109
|
type VisitLinkAEP = AEP<ACTION.VISITED, ACTION_SUBJECT.LINK, undefined, {
|
|
100
110
|
mode: MODE.RENDERER;
|
|
101
111
|
platform: PLATFORM.WEB;
|
|
@@ -132,6 +142,6 @@ export type MediaRenderErrorEvent = UIAEP<ACTION.ERRORED, ACTION_SUBJECT.RENDERE
|
|
|
132
142
|
external?: boolean;
|
|
133
143
|
reason: string;
|
|
134
144
|
}>;
|
|
135
|
-
export type AnalyticsEventPayload<T = void> = RendererStartAEP | RendererRenderedAEP | ComponentCrashErrorAEP | RendererUnsupportedContentLevelsTrackingSucceeded | RendererUnsupportedContentLevelsTrackingErrored | RendererSelectAllCaughtAEP | RendererSelectAllEscapedAEP | CodeBlockCopyAEP | CodeBlockWrapAEP | HeadingAnchorLinkButtonAEP | HoverLabelAEP | AnchorLinkAEP | TableSortColumnNotAllowedAEP | TableSortColumnAEP | TableWidthInfoAEP | VisitLinkAEP | VisitMediaLinkAEP | ExpandAEP | UnsupportedContentPayload | UnsupportedContentTooltipPayload | AnnotationAEP | AnnotationDeleteAEP | MediaLnkTransformedAEP | InvalidProsemirrorDocumentErrorAEP | NestedTableTransformedAEP | MediaRenderErrorEvent;
|
|
145
|
+
export type AnalyticsEventPayload<T = void> = RendererStartAEP | RendererRenderedAEP | ComponentCrashErrorAEP | RendererUnsupportedContentLevelsTrackingSucceeded | RendererUnsupportedContentLevelsTrackingErrored | RendererSelectAllCaughtAEP | RendererSelectAllEscapedAEP | CodeBlockCopyAEP | CodeBlockWrapAEP | HeadingAnchorLinkButtonAEP | HoverLabelAEP | AnchorLinkAEP | TableSortColumnNotAllowedAEP | TableSortColumnAEP | TableWidthInfoAEP | TableRendererHeightInfoAEP | VisitLinkAEP | VisitMediaLinkAEP | ExpandAEP | UnsupportedContentPayload | UnsupportedContentTooltipPayload | AnnotationAEP | AnnotationDeleteAEP | MediaLnkTransformedAEP | InvalidProsemirrorDocumentErrorAEP | NestedTableTransformedAEP | MediaRenderErrorEvent;
|
|
136
146
|
export type FireAnalyticsCallback = <T = void>(payload: AnalyticsEventPayload<T>) => void | undefined;
|
|
137
147
|
export {};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { AnalyticsEventPayload } from '../../analytics/events';
|
|
2
2
|
export declare const getWidthInfoPayload: (renderer: HTMLElement) => AnalyticsEventPayload | undefined;
|
|
3
|
+
export declare const getHeightInfoPayload: (renderer: HTMLElement) => AnalyticsEventPayload | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "124.10.
|
|
3
|
+
"version": "124.10.3",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"@atlaskit/status": "^3.0.0",
|
|
59
59
|
"@atlaskit/task-decision": "^19.2.0",
|
|
60
60
|
"@atlaskit/theme": "^21.0.0",
|
|
61
|
-
"@atlaskit/tmp-editor-statsig": "^13.
|
|
61
|
+
"@atlaskit/tmp-editor-statsig": "^13.32.0",
|
|
62
62
|
"@atlaskit/tokens": "^7.1.0",
|
|
63
|
-
"@atlaskit/tooltip": "^20.
|
|
63
|
+
"@atlaskit/tooltip": "^20.8.0",
|
|
64
64
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
65
65
|
"@babel/runtime": "^7.0.0",
|
|
66
66
|
"@emotion/react": "^11.7.1",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"uuid": "^3.1.0"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"@atlaskit/editor-common": "^110.
|
|
75
|
+
"@atlaskit/editor-common": "^110.24.0",
|
|
76
76
|
"@atlaskit/link-provider": "^4.0.0",
|
|
77
77
|
"@atlaskit/media-core": "^37.0.0",
|
|
78
78
|
"react": "^18.2.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@atlaskit/media-core": "^37.0.0",
|
|
90
90
|
"@atlaskit/media-integration-test-helpers": "workspace:^",
|
|
91
91
|
"@atlaskit/media-test-helpers": "^39.0.0",
|
|
92
|
-
"@atlaskit/mention": "^24.
|
|
92
|
+
"@atlaskit/mention": "^24.4.0",
|
|
93
93
|
"@atlaskit/modal-dialog": "^14.6.0",
|
|
94
94
|
"@atlaskit/navigation-next": "patch:@atlaskit/navigation-next@npm%3A9.0.17#~/.yarn/patches/@atlaskit-navigation-next-npm-9.0.17-958ca0ab9d.patch",
|
|
95
95
|
"@atlaskit/profilecard": "^24.20.0",
|
|
@@ -194,9 +194,6 @@
|
|
|
194
194
|
"platform_editor_bordered_panel_nested_in_table": {
|
|
195
195
|
"type": "boolean"
|
|
196
196
|
},
|
|
197
|
-
"platform_editor_nested_table_extension_comment_fix": {
|
|
198
|
-
"type": "boolean"
|
|
199
|
-
},
|
|
200
197
|
"platform_editor__renderer_indentation_text_margin": {
|
|
201
198
|
"type": "boolean"
|
|
202
199
|
},
|
|
@@ -241,6 +238,9 @@
|
|
|
241
238
|
},
|
|
242
239
|
"platform_editor_fix_sllv_margin_renderer": {
|
|
243
240
|
"type": "boolean"
|
|
241
|
+
},
|
|
242
|
+
"platform_editor_table_height_analytics_event": {
|
|
243
|
+
"type": "boolean"
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
}
|