@atlaskit/editor-core 150.0.3 → 151.0.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 +47 -0
- package/dist/cjs/actions/index.js +5 -23
- package/dist/cjs/create-editor/ErrorBoundary.js +113 -79
- package/dist/cjs/create-editor/ReactEditorView.js +145 -31
- package/dist/cjs/create-editor/create-plugins-list.js +4 -2
- package/dist/cjs/editor.js +101 -40
- package/dist/cjs/labs/next/presets/cxhtml.js +2 -1
- package/dist/cjs/plugins/analytics/types/enums.js +3 -1
- package/dist/cjs/plugins/base/index.js +4 -3
- package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +66 -36
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
- package/dist/cjs/plugins/card/index.js +13 -2
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/cjs/plugins/card/pm-plugins/main.js +7 -2
- package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +10 -3
- package/dist/cjs/plugins/code-block/toolbar.js +1 -1
- package/dist/cjs/plugins/emoji/styles.js +1 -1
- package/dist/cjs/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/cjs/plugins/extension/toolbar.js +28 -23
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +8 -3
- package/dist/cjs/plugins/find-replace/ui/Find.js +27 -7
- package/dist/cjs/plugins/hyperlink/pm-plugins/keymap.js +3 -3
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/cjs/plugins/hyperlink/utils.js +6 -69
- package/dist/cjs/plugins/media/index.js +14 -3
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +24 -10
- package/dist/cjs/plugins/media/nodeviews/mediaInline.js +179 -0
- package/dist/cjs/plugins/media/pm-plugins/main.js +18 -9
- package/dist/cjs/plugins/media/toolbar/index.js +49 -17
- package/dist/cjs/plugins/media/toolbar/utils.js +20 -2
- package/dist/cjs/plugins/media/utils/media-files.js +67 -1
- package/dist/cjs/plugins/panel/index.js +2 -3
- package/dist/cjs/plugins/panel/message.js +47 -0
- package/dist/cjs/plugins/panel/toolbar.js +64 -84
- package/dist/cjs/plugins/panel/utils.js +2 -2
- package/dist/cjs/plugins/paste/linkify-md-plugin.js +3 -3
- package/dist/cjs/plugins/status/styles.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/cjs/profiler/render-count.js +82 -0
- package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/cjs/utils/react-hooks/use-component-renderer-tracking/index.js +55 -19
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +6 -28
- package/dist/es2019/create-editor/ErrorBoundary.js +73 -60
- package/dist/es2019/create-editor/ReactEditorView.js +130 -23
- package/dist/es2019/create-editor/create-plugins-list.js +4 -2
- package/dist/es2019/editor.js +74 -35
- package/dist/es2019/labs/next/presets/cxhtml.js +2 -1
- package/dist/es2019/plugins/analytics/types/enums.js +3 -1
- package/dist/es2019/plugins/base/index.js +4 -3
- package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +63 -35
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +2 -1
- package/dist/es2019/plugins/card/index.js +7 -2
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/es2019/plugins/card/pm-plugins/main.js +9 -2
- package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +12 -5
- package/dist/es2019/plugins/code-block/toolbar.js +1 -1
- package/dist/es2019/plugins/emoji/styles.js +2 -0
- package/dist/es2019/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/es2019/plugins/extension/toolbar.js +30 -25
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +8 -4
- package/dist/es2019/plugins/find-replace/ui/Find.js +27 -6
- package/dist/es2019/plugins/hyperlink/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/es2019/plugins/hyperlink/utils.js +3 -59
- package/dist/es2019/plugins/media/index.js +13 -4
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +16 -7
- package/dist/es2019/plugins/media/nodeviews/mediaInline.js +88 -0
- package/dist/es2019/plugins/media/pm-plugins/main.js +20 -11
- package/dist/es2019/plugins/media/toolbar/index.js +44 -15
- package/dist/es2019/plugins/media/toolbar/utils.js +16 -0
- package/dist/es2019/plugins/media/utils/media-files.js +68 -2
- package/dist/es2019/plugins/panel/index.js +3 -4
- package/dist/es2019/plugins/panel/message.js +38 -0
- package/dist/es2019/plugins/panel/toolbar.js +52 -71
- package/dist/es2019/plugins/panel/utils.js +2 -2
- package/dist/es2019/plugins/paste/linkify-md-plugin.js +2 -2
- package/dist/es2019/plugins/status/styles.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/es2019/profiler/render-count.js +60 -0
- package/dist/es2019/ui/Appearance/Comment/Comment.js +4 -2
- package/dist/es2019/utils/react-hooks/use-component-renderer-tracking/index.js +51 -18
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +6 -24
- package/dist/esm/create-editor/ErrorBoundary.js +113 -78
- package/dist/esm/create-editor/ReactEditorView.js +146 -31
- package/dist/esm/create-editor/create-plugins-list.js +4 -2
- package/dist/esm/editor.js +100 -40
- package/dist/esm/labs/next/presets/cxhtml.js +2 -1
- package/dist/esm/plugins/analytics/types/enums.js +3 -1
- package/dist/esm/plugins/base/index.js +4 -3
- package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +64 -36
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
- package/dist/esm/plugins/card/index.js +13 -2
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/esm/plugins/card/pm-plugins/main.js +7 -2
- package/dist/esm/plugins/card/pm-plugins/util/resolve.js +12 -5
- package/dist/esm/plugins/code-block/toolbar.js +1 -1
- package/dist/esm/plugins/emoji/styles.js +1 -1
- package/dist/esm/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/esm/plugins/extension/toolbar.js +28 -23
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +8 -4
- package/dist/esm/plugins/find-replace/ui/Find.js +27 -7
- package/dist/esm/plugins/hyperlink/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/esm/plugins/hyperlink/utils.js +3 -59
- package/dist/esm/plugins/media/index.js +14 -4
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +24 -10
- package/dist/esm/plugins/media/nodeviews/mediaInline.js +147 -0
- package/dist/esm/plugins/media/pm-plugins/main.js +19 -11
- package/dist/esm/plugins/media/toolbar/index.js +47 -19
- package/dist/esm/plugins/media/toolbar/utils.js +15 -1
- package/dist/esm/plugins/media/utils/media-files.js +60 -2
- package/dist/esm/plugins/panel/index.js +3 -4
- package/dist/esm/plugins/panel/message.js +38 -0
- package/dist/esm/plugins/panel/toolbar.js +57 -77
- package/dist/esm/plugins/panel/utils.js +2 -2
- package/dist/esm/plugins/paste/linkify-md-plugin.js +2 -2
- package/dist/esm/plugins/status/styles.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/esm/profiler/render-count.js +57 -0
- package/dist/esm/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/esm/utils/react-hooks/use-component-renderer-tracking/index.js +53 -20
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/create-editor/ErrorBoundary.d.ts +6 -6
- package/dist/types/create-editor/ReactEditorView.d.ts +15 -3
- package/dist/types/editor.d.ts +2 -0
- package/dist/types/plugins/analytics/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/enums.d.ts +4 -2
- package/dist/types/plugins/analytics/types/events.d.ts +7 -2
- package/dist/types/plugins/analytics/types/general-events.d.ts +4 -1
- package/dist/types/plugins/analytics/types/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/insert-events.d.ts +6 -1
- package/dist/types/plugins/analytics/types/link-tool-bar-events.d.ts +1 -0
- package/dist/types/plugins/base/index.d.ts +1 -0
- package/dist/types/plugins/base/pm-plugins/frozen-editor.d.ts +3 -2
- package/dist/types/plugins/card/pm-plugins/main.d.ts +2 -3
- package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +2 -1
- package/dist/types/plugins/card/types.d.ts +6 -0
- package/dist/types/plugins/extension/types.d.ts +0 -2
- package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/types.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -1
- package/dist/types/plugins/hyperlink/utils.d.ts +0 -21
- package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +27 -0
- package/dist/types/plugins/media/pm-plugins/main.d.ts +2 -2
- package/dist/types/plugins/media/toolbar/utils.d.ts +2 -0
- package/dist/types/plugins/media/utils/media-files.d.ts +8 -0
- package/dist/types/plugins/panel/message.d.ts +37 -0
- package/dist/types/plugins/panel/toolbar.d.ts +4 -37
- package/dist/types/plugins/panel/types.d.ts +1 -0
- package/dist/types/profiler/render-count.d.ts +14 -0
- package/dist/types/types/feature-flags.d.ts +8 -0
- package/dist/types/ui/LinkSearch/types.d.ts +1 -0
- package/dist/types/utils/react-hooks/use-component-renderer-tracking/index.d.ts +17 -1
- package/package.json +19 -16
- package/dist/cjs/plugins/caption/nodeviews/index.test.js +0 -135
- package/dist/cjs/plugins/caption/pm-plugins/keymap.test.js +0 -203
- package/dist/cjs/plugins/caption/pm-plugins/main.test.js +0 -141
- package/dist/cjs/plugins/code-block/language-list.test.js +0 -74
- package/dist/cjs/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -101
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -98
- package/dist/cjs/plugins/media/commands/captions.test.js +0 -149
- package/dist/cjs/plugins/media/commands/linking.test.js +0 -296
- package/dist/cjs/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -50
- package/dist/cjs/plugins/panel/toolbar.test.js +0 -250
- package/dist/cjs/ui/ColorPickerButton/index.test.js +0 -123
- package/dist/cjs/ui/PortalProvider/index.test.js +0 -139
- package/dist/es2019/plugins/caption/nodeviews/index.test.js +0 -122
- package/dist/es2019/plugins/caption/pm-plugins/keymap.test.js +0 -193
- package/dist/es2019/plugins/caption/pm-plugins/main.test.js +0 -132
- package/dist/es2019/plugins/code-block/language-list.test.js +0 -69
- package/dist/es2019/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -83
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
- package/dist/es2019/plugins/media/commands/captions.test.js +0 -126
- package/dist/es2019/plugins/media/commands/linking.test.js +0 -208
- package/dist/es2019/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
- package/dist/es2019/plugins/panel/toolbar.test.js +0 -200
- package/dist/es2019/ui/ColorPickerButton/index.test.js +0 -88
- package/dist/es2019/ui/PortalProvider/index.test.js +0 -115
- package/dist/esm/plugins/caption/nodeviews/index.test.js +0 -125
- package/dist/esm/plugins/caption/pm-plugins/keymap.test.js +0 -195
- package/dist/esm/plugins/caption/pm-plugins/main.test.js +0 -124
- package/dist/esm/plugins/code-block/language-list.test.js +0 -71
- package/dist/esm/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -92
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
- package/dist/esm/plugins/media/commands/captions.test.js +0 -135
- package/dist/esm/plugins/media/commands/linking.test.js +0 -268
- package/dist/esm/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
- package/dist/esm/plugins/panel/toolbar.test.js +0 -230
- package/dist/esm/ui/ColorPickerButton/index.test.js +0 -107
- package/dist/esm/ui/PortalProvider/index.test.js +0 -129
|
@@ -1,33 +1,66 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
1
|
+
import { useMemo, useEffect, useRef } from 'react';
|
|
2
|
+
import debounce from 'lodash/debounce';
|
|
2
3
|
import { getShallowPropsDifference, getPropsDifference } from '../../compare';
|
|
3
4
|
import { EVENT_TYPE } from '../../../plugins/analytics';
|
|
4
|
-
export function useComponentRenderTracking(
|
|
5
|
+
export function useComponentRenderTracking({
|
|
6
|
+
onRender,
|
|
7
|
+
propsDiffingOptions,
|
|
8
|
+
zeroBasedCount = true
|
|
9
|
+
}) {
|
|
5
10
|
const propsRef = useRef();
|
|
6
|
-
const renderCountRef = useRef(0);
|
|
11
|
+
const renderCountRef = useRef(zeroBasedCount ? 0 : 1);
|
|
7
12
|
useEffect(() => {
|
|
8
13
|
const lastProps = propsRef.current;
|
|
9
14
|
const renderCount = renderCountRef.current;
|
|
15
|
+
let propsDifference;
|
|
10
16
|
|
|
11
|
-
if (lastProps) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
17
|
+
if (propsDiffingOptions !== null && propsDiffingOptions !== void 0 && propsDiffingOptions.enabled && lastProps) {
|
|
18
|
+
propsDifference = propsDiffingOptions !== null && propsDiffingOptions !== void 0 && propsDiffingOptions.useShallow ? getShallowPropsDifference(lastProps, propsDiffingOptions.props) : getPropsDifference(lastProps, propsDiffingOptions.props, 0, 2, propsDiffingOptions === null || propsDiffingOptions === void 0 ? void 0 : propsDiffingOptions.propsToIgnore);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const result = {
|
|
22
|
+
renderCount,
|
|
23
|
+
propsDifference
|
|
24
|
+
};
|
|
25
|
+
onRender(result);
|
|
26
|
+
|
|
27
|
+
if (propsDiffingOptions !== null && propsDiffingOptions !== void 0 && propsDiffingOptions.enabled) {
|
|
28
|
+
propsRef.current = propsDiffingOptions.props;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
propsRef.current = props;
|
|
27
31
|
renderCountRef.current = renderCountRef.current + 1;
|
|
28
32
|
}); // No dependencies run on each render
|
|
29
33
|
}
|
|
30
34
|
export function RenderTracking(props) {
|
|
31
|
-
|
|
35
|
+
const debouncedHandleAnalyticsEvent = useMemo(() => debounce(props.handleAnalyticsEvent, 500), [props.handleAnalyticsEvent]);
|
|
36
|
+
useComponentRenderTracking({
|
|
37
|
+
onRender: ({
|
|
38
|
+
renderCount,
|
|
39
|
+
propsDifference
|
|
40
|
+
}) => {
|
|
41
|
+
if (!renderCount) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
debouncedHandleAnalyticsEvent({
|
|
46
|
+
payload: {
|
|
47
|
+
action: props.action,
|
|
48
|
+
actionSubject: props.actionSubject,
|
|
49
|
+
attributes: {
|
|
50
|
+
count: renderCount,
|
|
51
|
+
propsDifference: propsDifference
|
|
52
|
+
},
|
|
53
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
propsDiffingOptions: {
|
|
58
|
+
enabled: true,
|
|
59
|
+
props: props.componentProps,
|
|
60
|
+
propsToIgnore: props.propsToIgnore,
|
|
61
|
+
useShallow: props.useShallow
|
|
62
|
+
},
|
|
63
|
+
zeroBasedCount: true
|
|
64
|
+
});
|
|
32
65
|
return null;
|
|
33
66
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -4,7 +4,7 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
4
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
6
|
import { Node } from 'prosemirror-model';
|
|
7
|
-
import { TextSelection
|
|
7
|
+
import { TextSelection } from 'prosemirror-state';
|
|
8
8
|
import { toJSON } from '../utils';
|
|
9
9
|
import { processRawValue, isEmptyDocument } from '../utils/document';
|
|
10
10
|
import { getEditorValueWithMedia, __temporaryFixForConfigPanel as _temporaryFixForConfigPanel } from '../utils/action';
|
|
@@ -244,31 +244,13 @@ var EditorActions = /*#__PURE__*/function () {
|
|
|
244
244
|
return false;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return false;
|
|
253
|
-
} // In case of replacing a whole document, we only need a content of a top level node e.g. document.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
var tr = state.tr.replaceWith(0, state.doc.nodeSize - 2, content.content);
|
|
257
|
-
|
|
258
|
-
if (!shouldScrollToBottom && !tr.selectionSet) {
|
|
259
|
-
// Restore selection at start of document instead of the end.
|
|
260
|
-
tr.setSelection(Selection.atStart(tr.doc));
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
if (shouldScrollToBottom) {
|
|
264
|
-
tr = tr.scrollIntoView();
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (!shouldAddToHistory) {
|
|
268
|
-
tr.setMeta('addToHistory', false);
|
|
247
|
+
if (this.eventDispatcher) {
|
|
248
|
+
this.eventDispatcher.emit('resetEditorState', {
|
|
249
|
+
doc: rawValue,
|
|
250
|
+
shouldScrollToBottom: shouldScrollToBottom
|
|
251
|
+
});
|
|
269
252
|
}
|
|
270
253
|
|
|
271
|
-
this.editorView.dispatch(tr);
|
|
272
254
|
return true;
|
|
273
255
|
}
|
|
274
256
|
}, {
|
|
@@ -8,6 +8,10 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
8
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
10
|
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
|
+
|
|
11
15
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
16
|
|
|
13
17
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
@@ -16,6 +20,7 @@ import React from 'react';
|
|
|
16
20
|
import uuid from 'uuid';
|
|
17
21
|
import memoizeOne from 'memoize-one';
|
|
18
22
|
import { sniffUserBrowserExtensions } from '@atlaskit/editor-common';
|
|
23
|
+
import { ExperienceStore } from '@atlaskit/editor-common/ufo';
|
|
19
24
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '../plugins/analytics';
|
|
20
25
|
import { editorAnalyticsChannel } from '../plugins/analytics/consts';
|
|
21
26
|
import { getFeatureFlags } from '../plugins/feature-flags-context';
|
|
@@ -26,16 +31,12 @@ export var ErrorBoundaryWithEditorView = /*#__PURE__*/function (_React$Component
|
|
|
26
31
|
|
|
27
32
|
var _super = _createSuper(ErrorBoundaryWithEditorView);
|
|
28
33
|
|
|
29
|
-
function ErrorBoundaryWithEditorView() {
|
|
34
|
+
function ErrorBoundaryWithEditorView(props) {
|
|
30
35
|
var _this;
|
|
31
36
|
|
|
32
37
|
_classCallCheck(this, ErrorBoundaryWithEditorView);
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
args[_key] = arguments[_key];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
39
|
+
_this = _super.call(this, props);
|
|
39
40
|
|
|
40
41
|
_defineProperty(_assertThisInitialized(_this), "browserExtensions", undefined);
|
|
41
42
|
|
|
@@ -51,102 +52,138 @@ export var ErrorBoundaryWithEditorView = /*#__PURE__*/function (_React$Component
|
|
|
51
52
|
return getFeatureFlags(editorView.state);
|
|
52
53
|
}));
|
|
53
54
|
|
|
54
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
_this.getProductName().then(function (product) {
|
|
58
|
-
if (createAnalyticsEvent) {
|
|
59
|
-
var error = analyticsErrorPayload.error,
|
|
60
|
-
errorInfo = analyticsErrorPayload.errorInfo,
|
|
61
|
-
errorStack = analyticsErrorPayload.errorStack;
|
|
62
|
-
var sharedId = uuid();
|
|
63
|
-
var event = {
|
|
64
|
-
action: ACTION.EDITOR_CRASHED,
|
|
65
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
66
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
67
|
-
attributes: {
|
|
68
|
-
product: product,
|
|
69
|
-
browserInfo: window && window.navigator && window.navigator.userAgent ? window.navigator.userAgent : 'unknown',
|
|
70
|
-
error: error,
|
|
71
|
-
errorInfo: errorInfo,
|
|
72
|
-
errorId: sharedId,
|
|
73
|
-
browserExtensions: _this.browserExtensions
|
|
74
|
-
}
|
|
75
|
-
}; // Add doc structure if the feature flag is on
|
|
55
|
+
_defineProperty(_assertThisInitialized(_this), "sendErrorData", /*#__PURE__*/function () {
|
|
56
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(analyticsErrorPayload) {
|
|
57
|
+
var product, error, errorInfo, errorStack, sharedId, attributes, _this$experienceStore;
|
|
76
58
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
59
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
60
|
+
while (1) {
|
|
61
|
+
switch (_context.prev = _context.next) {
|
|
62
|
+
case 0:
|
|
63
|
+
_context.next = 2;
|
|
64
|
+
return _this.getProductName();
|
|
65
|
+
|
|
66
|
+
case 2:
|
|
67
|
+
product = _context.sent;
|
|
68
|
+
error = analyticsErrorPayload.error, errorInfo = analyticsErrorPayload.errorInfo, errorStack = analyticsErrorPayload.errorStack;
|
|
69
|
+
sharedId = uuid();
|
|
70
|
+
attributes = {
|
|
71
|
+
product: product,
|
|
72
|
+
browserInfo: window && window.navigator && window.navigator.userAgent ? window.navigator.userAgent : 'unknown',
|
|
73
|
+
error: error,
|
|
74
|
+
errorInfo: errorInfo,
|
|
75
|
+
errorId: sharedId,
|
|
76
|
+
browserExtensions: _this.browserExtensions,
|
|
77
|
+
docStructure: _this.featureFlags.errorBoundaryDocStructure && _this.props.editorView ? getDocStructure(_this.props.editorView.state.doc, {
|
|
78
|
+
compact: true
|
|
79
|
+
}) : undefined
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
_this.fireAnalyticsEvent({
|
|
83
|
+
action: ACTION.EDITOR_CRASHED,
|
|
84
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
85
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
86
|
+
attributes: attributes
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
_this.fireAnalyticsEvent({
|
|
90
|
+
action: ACTION.EDITOR_CRASHED_ADDITIONAL_INFORMATION,
|
|
91
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
92
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
93
|
+
attributes: {
|
|
94
|
+
errorStack: errorStack,
|
|
95
|
+
errorId: sharedId
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
if (_this.featureFlags.ufo && _this.props.editorView) {
|
|
100
|
+
(_this$experienceStore = _this.experienceStore) === null || _this$experienceStore === void 0 ? void 0 : _this$experienceStore.failAll(_objectSpread(_objectSpread({}, _this.getExperienceMetadata(attributes)), {}, {
|
|
101
|
+
errorStack: errorStack
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
82
104
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
87
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
88
|
-
attributes: {
|
|
89
|
-
errorStack: errorStack,
|
|
90
|
-
errorId: sharedId
|
|
105
|
+
case 9:
|
|
106
|
+
case "end":
|
|
107
|
+
return _context.stop();
|
|
91
108
|
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
}).catch(function (e) {
|
|
102
|
-
// eslint-disable-next-line no-console
|
|
103
|
-
console.error('Failed to resolve product name from contextIdentifierProvider.', e);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
109
|
+
}
|
|
110
|
+
}, _callee);
|
|
111
|
+
}));
|
|
112
|
+
|
|
113
|
+
return function (_x) {
|
|
114
|
+
return _ref.apply(this, arguments);
|
|
115
|
+
};
|
|
116
|
+
}());
|
|
106
117
|
|
|
107
|
-
_defineProperty(_assertThisInitialized(_this), "getProductName", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
118
|
+
_defineProperty(_assertThisInitialized(_this), "getProductName", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
108
119
|
var contextIdentifierProvider, context;
|
|
109
|
-
return _regeneratorRuntime.wrap(function
|
|
120
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
110
121
|
while (1) {
|
|
111
|
-
switch (
|
|
122
|
+
switch (_context2.prev = _context2.next) {
|
|
112
123
|
case 0:
|
|
113
124
|
contextIdentifierProvider = _this.props.contextIdentifierProvider;
|
|
114
125
|
|
|
115
126
|
if (!contextIdentifierProvider) {
|
|
116
|
-
|
|
127
|
+
_context2.next = 7;
|
|
117
128
|
break;
|
|
118
129
|
}
|
|
119
130
|
|
|
120
|
-
|
|
131
|
+
_context2.next = 4;
|
|
121
132
|
return contextIdentifierProvider;
|
|
122
133
|
|
|
123
134
|
case 4:
|
|
124
|
-
context =
|
|
135
|
+
context = _context2.sent;
|
|
125
136
|
|
|
126
137
|
if (!context.product) {
|
|
127
|
-
|
|
138
|
+
_context2.next = 7;
|
|
128
139
|
break;
|
|
129
140
|
}
|
|
130
141
|
|
|
131
|
-
return
|
|
142
|
+
return _context2.abrupt("return", context.product);
|
|
132
143
|
|
|
133
144
|
case 7:
|
|
134
|
-
return
|
|
145
|
+
return _context2.abrupt("return", 'atlaskit');
|
|
135
146
|
|
|
136
147
|
case 8:
|
|
137
148
|
case "end":
|
|
138
|
-
return
|
|
149
|
+
return _context2.stop();
|
|
139
150
|
}
|
|
140
151
|
}
|
|
141
|
-
},
|
|
152
|
+
}, _callee2);
|
|
142
153
|
})));
|
|
143
154
|
|
|
155
|
+
_defineProperty(_assertThisInitialized(_this), "fireAnalyticsEvent", function (event) {
|
|
156
|
+
var _this$props$createAna, _this$props;
|
|
157
|
+
|
|
158
|
+
(_this$props$createAna = (_this$props = _this.props).createAnalyticsEvent) === null || _this$props$createAna === void 0 ? void 0 : _this$props$createAna.call(_this$props, event).fire(editorAnalyticsChannel);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
_defineProperty(_assertThisInitialized(_this), "getExperienceMetadata", function (attributes) {
|
|
162
|
+
var _attributes$browserEx;
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
browserInfo: attributes.browserInfo,
|
|
166
|
+
error: attributes.error.toString(),
|
|
167
|
+
errorInfo: {
|
|
168
|
+
componentStack: attributes.errorInfo.componentStack
|
|
169
|
+
},
|
|
170
|
+
errorId: attributes.errorId,
|
|
171
|
+
browserExtensions: (_attributes$browserEx = attributes.browserExtensions) === null || _attributes$browserEx === void 0 ? void 0 : _attributes$browserEx.toString(),
|
|
172
|
+
docStructure: attributes.docStructure
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
if (props.editorView) {
|
|
177
|
+
_this.experienceStore = ExperienceStore.getInstance(props.editorView);
|
|
178
|
+
}
|
|
179
|
+
|
|
144
180
|
return _this;
|
|
145
181
|
}
|
|
146
182
|
|
|
147
183
|
_createClass(ErrorBoundaryWithEditorView, [{
|
|
148
184
|
key: "featureFlags",
|
|
149
|
-
get:
|
|
185
|
+
get: // Memoizing this as react alternative suggestion of https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops
|
|
186
|
+
function get() {
|
|
150
187
|
return this.getFeatureFlags(this.props.editorView);
|
|
151
188
|
}
|
|
152
189
|
}, {
|
|
@@ -154,13 +191,11 @@ export var ErrorBoundaryWithEditorView = /*#__PURE__*/function (_React$Component
|
|
|
154
191
|
value: function componentDidCatch(error, errorInfo) {
|
|
155
192
|
var _this2 = this;
|
|
156
193
|
|
|
157
|
-
|
|
158
|
-
this.fireAnalytics({
|
|
194
|
+
this.sendErrorData({
|
|
159
195
|
error: error.toString(),
|
|
160
196
|
errorInfo: errorInfo,
|
|
161
197
|
errorStack: error.stack
|
|
162
|
-
}); //
|
|
163
|
-
// // Update state to allow a re-render to attempt graceful recovery (in the event that
|
|
198
|
+
}); // // Update state to allow a re-render to attempt graceful recovery (in the event that
|
|
164
199
|
// // the error was caused by a race condition or is intermittent)
|
|
165
200
|
|
|
166
201
|
this.setState({
|
|
@@ -180,12 +215,12 @@ export var ErrorBoundaryWithEditorView = /*#__PURE__*/function (_React$Component
|
|
|
180
215
|
}, {
|
|
181
216
|
key: "componentDidMount",
|
|
182
217
|
value: function () {
|
|
183
|
-
var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
184
|
-
return _regeneratorRuntime.wrap(function
|
|
218
|
+
var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
219
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
185
220
|
while (1) {
|
|
186
|
-
switch (
|
|
221
|
+
switch (_context3.prev = _context3.next) {
|
|
187
222
|
case 0:
|
|
188
|
-
|
|
223
|
+
_context3.next = 2;
|
|
189
224
|
return sniffUserBrowserExtensions({
|
|
190
225
|
extensions: ['grammarly'],
|
|
191
226
|
async: true,
|
|
@@ -193,14 +228,14 @@ export var ErrorBoundaryWithEditorView = /*#__PURE__*/function (_React$Component
|
|
|
193
228
|
});
|
|
194
229
|
|
|
195
230
|
case 2:
|
|
196
|
-
this.browserExtensions =
|
|
231
|
+
this.browserExtensions = _context3.sent;
|
|
197
232
|
|
|
198
233
|
case 3:
|
|
199
234
|
case "end":
|
|
200
|
-
return
|
|
235
|
+
return _context3.stop();
|
|
201
236
|
}
|
|
202
237
|
}
|
|
203
|
-
},
|
|
238
|
+
}, _callee3, this);
|
|
204
239
|
}));
|
|
205
240
|
|
|
206
241
|
function componentDidMount() {
|