@atlaskit/editor-common 128.3.2 → 128.4.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/block-node-badges/package.json +10 -0
  3. package/dist/cjs/analytics/types/enums.js +0 -12
  4. package/dist/cjs/block-node-badges.js +98 -0
  5. package/dist/cjs/extensibility/Extension/Extension/index.js +20 -2
  6. package/dist/cjs/extensibility/Extension/ExtensionCommentBadge.js +110 -0
  7. package/dist/cjs/media-single/MediaBadges.js +12 -85
  8. package/dist/cjs/monitoring/error.js +1 -1
  9. package/dist/cjs/react-node-view/getInlineNodeViewProducer.js +0 -13
  10. package/dist/cjs/react-node-view/index.js +0 -14
  11. package/dist/cjs/ui/DropList/index.js +1 -1
  12. package/dist/cjs/utils/index.js +0 -47
  13. package/dist/es2019/analytics/types/enums.js +0 -12
  14. package/dist/es2019/block-node-badges.js +84 -0
  15. package/dist/es2019/extensibility/Extension/Extension/index.js +17 -3
  16. package/dist/es2019/extensibility/Extension/ExtensionCommentBadge.js +60 -0
  17. package/dist/es2019/media-single/MediaBadges.js +12 -79
  18. package/dist/es2019/monitoring/error.js +1 -1
  19. package/dist/es2019/react-node-view/getInlineNodeViewProducer.js +1 -15
  20. package/dist/es2019/react-node-view/index.js +0 -15
  21. package/dist/es2019/ui/DropList/index.js +1 -1
  22. package/dist/es2019/utils/index.js +0 -5
  23. package/dist/esm/analytics/types/enums.js +0 -12
  24. package/dist/esm/block-node-badges.js +88 -0
  25. package/dist/esm/extensibility/Extension/Extension/index.js +21 -3
  26. package/dist/esm/extensibility/Extension/ExtensionCommentBadge.js +101 -0
  27. package/dist/esm/media-single/MediaBadges.js +12 -82
  28. package/dist/esm/monitoring/error.js +1 -1
  29. package/dist/esm/react-node-view/getInlineNodeViewProducer.js +1 -14
  30. package/dist/esm/react-node-view/index.js +0 -14
  31. package/dist/esm/ui/DropList/index.js +1 -1
  32. package/dist/esm/utils/index.js +0 -5
  33. package/dist/types/analytics/index.d.ts +1 -2
  34. package/dist/types/analytics/types/enums.d.ts +0 -12
  35. package/dist/types/analytics/types/events.d.ts +1 -3
  36. package/dist/types/analytics/types/general-events.d.ts +2 -15
  37. package/dist/types/block-node-badges.d.ts +14 -0
  38. package/dist/types/extensibility/Extension/ExtensionCommentBadge.d.ts +8 -0
  39. package/dist/types/extensibility/types.d.ts +29 -2
  40. package/dist/types/media-single/MediaBadges.d.ts +4 -8
  41. package/dist/types/types/index.d.ts +1 -1
  42. package/dist/types/types/performance-tracking.d.ts +0 -22
  43. package/dist/types/utils/index.d.ts +0 -5
  44. package/package.json +5 -1
  45. package/analytics/types/performance-report/package.json +0 -10
  46. package/dist/cjs/analytics/types/performance-report.js +0 -1
  47. package/dist/cjs/utils/get-performance-options.js +0 -65
  48. package/dist/cjs/utils/performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.js +0 -10
  49. package/dist/cjs/utils/performance/TTI_SEVERITY_THRESHOLD_DEFAULTS.js +0 -10
  50. package/dist/cjs/utils/performance/measure-tti.js +0 -112
  51. package/dist/cjs/utils/startMeasureReactNodeViewRendered.js +0 -11
  52. package/dist/es2019/analytics/types/performance-report.js +0 -0
  53. package/dist/es2019/utils/get-performance-options.js +0 -54
  54. package/dist/es2019/utils/performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.js +0 -4
  55. package/dist/es2019/utils/performance/TTI_SEVERITY_THRESHOLD_DEFAULTS.js +0 -4
  56. package/dist/es2019/utils/performance/measure-tti.js +0 -91
  57. package/dist/es2019/utils/startMeasureReactNodeViewRendered.js +0 -6
  58. package/dist/esm/analytics/types/performance-report.js +0 -0
  59. package/dist/esm/utils/get-performance-options.js +0 -53
  60. package/dist/esm/utils/performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.js +0 -4
  61. package/dist/esm/utils/performance/TTI_SEVERITY_THRESHOLD_DEFAULTS.js +0 -4
  62. package/dist/esm/utils/performance/measure-tti.js +0 -94
  63. package/dist/esm/utils/startMeasureReactNodeViewRendered.js +0 -5
  64. package/dist/types/analytics/types/performance-report.d.ts +0 -24
  65. package/dist/types/utils/get-performance-options.d.ts +0 -14
  66. package/dist/types/utils/performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.d.ts +0 -4
  67. package/dist/types/utils/performance/TTI_SEVERITY_THRESHOLD_DEFAULTS.d.ts +0 -4
  68. package/dist/types/utils/performance/measure-tti.d.ts +0 -8
  69. package/dist/types/utils/startMeasureReactNodeViewRendered.d.ts +0 -3
  70. package/performance/measure-tti/package.json +0 -10
  71. package/utils/get-performance-options/package.json +0 -10
@@ -50,14 +50,12 @@ export let ACTION = /*#__PURE__*/function (ACTION) {
50
50
  ACTION["DISPLAYED"] = "displayed";
51
51
  ACTION["DIVERGED"] = "diverged";
52
52
  ACTION["DISPATCHED_INVALID_TRANSACTION"] = "dispatchedInvalidTransaction";
53
- ACTION["DISPATCHED_VALID_TRANSACTION"] = "dispatchedValidTransaction";
54
53
  ACTION["DOUBLE_CLICKED"] = "doubleClicked";
55
54
  ACTION["DRAGGED"] = "dragged";
56
55
  ACTION["EDITED"] = "edited";
57
56
  ACTION["EDITOR_CRASHED"] = "unhandledErrorCaught";
58
57
  ACTION["EDITOR_CRASHED_ADDITIONAL_INFORMATION"] = "unhandledErrorCaughtAdditionalInfov2";
59
58
  ACTION["EDITOR_MOUNTED"] = "mounted";
60
- ACTION["EDITOR_CONTENT_RETRIEVAL_PERFORMED"] = "contentRetrievalPerformed";
61
59
  ACTION["RE_RENDERED"] = "reRendered";
62
60
  ACTION["ENDED"] = "ended";
63
61
  ACTION["ENTERED"] = "entered";
@@ -116,7 +114,6 @@ export let ACTION = /*#__PURE__*/function (ACTION) {
116
114
  ACTION["PRESSED"] = "pressed";
117
115
  ACTION["QUICK_INSERT_INFORMATION"] = "quickInsertInformation";
118
116
  ACTION["PROSEMIRROR_RENDERED"] = "proseMirrorRendered";
119
- ACTION["REACT_NODEVIEW_RENDERED"] = "reactNodeViewRendered";
120
117
  ACTION["REFERENCE_SYNCED_BLOCK_DELETE"] = "referenceSyncedBlockDelete";
121
118
  ACTION["REFERENCE_SYNCED_BLOCK_UPDATE"] = "referenceSyncedBlockUpdate";
122
119
  ACTION["REFERENCE_SYNCED_BLOCK_UNSYNC"] = "referenceSyncedBlockUnsync";
@@ -172,18 +169,9 @@ export let ACTION = /*#__PURE__*/function (ACTION) {
172
169
  ACTION["UPLOAD_EXTERNAL_FAIL"] = "uploadExternalFailed";
173
170
  ACTION["VIEWED"] = "viewed";
174
171
  ACTION["VISITED"] = "visited";
175
- ACTION["WITH_PLUGIN_STATE_CALLED"] = "withPluginStateCalled";
176
172
  ACTION["RENDERED"] = "rendered";
177
- ACTION["RENDERED_SAMPLED"] = "renderedSampled";
178
173
  ACTION["REASONING_VIEWED"] = "reasoningViewed";
179
174
  ACTION["ON_EDITOR_READY_CALLBACK"] = "onEditorReadyCallback";
180
- /**
181
- * @private
182
- * @deprecated
183
- *
184
- * This is no longer used and can be removed at a later date
185
- */
186
- ACTION["ON_CHANGE_CALLBACK"] = "onChangeCalled";
187
175
  ACTION["NESTED_TABLE_TRANSFORMED"] = "nestedTableTransformed";
188
176
  ACTION["CONTAINER_NODE_TRANSFORMED"] = "containerNodeTransformed";
189
177
  ACTION["NATIVE_EMBEDS_TRANSFORMED"] = "nativeEmbedsTransformed";
@@ -0,0 +1,84 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import debounce from 'lodash/debounce';
3
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
4
+ // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
5
+ import { Box, xcss } from '@atlaskit/primitives';
6
+ const BADGE_VISIBILITY_BREAKPOINT = 200;
7
+ const containerStyles = xcss({
8
+ display: 'flex',
9
+ position: 'absolute',
10
+ top: 'space.0',
11
+ right: 'space.0',
12
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
13
+ lineHeight: "var(--ds-space-200, 16px)",
14
+ gap: 'space.025',
15
+ zIndex: 'card',
16
+ height: 'fit-content',
17
+ width: 'fit-content',
18
+ margin: 'space.075'
19
+ });
20
+
21
+ // The above styles are used for both editor and renderer, and in renderer the
22
+ // document body is the main scroll area. This means it overscrolls the primary
23
+ // toolbar, where the z-index is "2". We have to hack in our own z-index less
24
+ // than that to ensure our badge appears under the toolbar when scrolled.
25
+ const hackedZIndexStyles = xcss({
26
+ zIndex: '1'
27
+ });
28
+ const resizeOffsetStyles = xcss({
29
+ right: 'space.150'
30
+ });
31
+ const getBadgeVisible = (width, height) => {
32
+ return width && width < BADGE_VISIBILITY_BREAKPOINT || height && height < BADGE_VISIBILITY_BREAKPOINT ? false : true;
33
+ };
34
+ export const BlockNodeBadges = ({
35
+ children,
36
+ element,
37
+ width,
38
+ height,
39
+ extendedResizeOffset,
40
+ useMinimumZIndex = false
41
+ }) => {
42
+ const [visible, setVisible] = useState(getBadgeVisible(width, height));
43
+ useEffect(() => {
44
+ const observer = new ResizeObserver(debounce(entries => {
45
+ const [entry] = entries;
46
+ const {
47
+ width,
48
+ height
49
+ } = entry.contentRect;
50
+ setVisible(getBadgeVisible(width, height));
51
+ }));
52
+ if (element) {
53
+ // Ignored via go/ees005
54
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
55
+ observer.observe(element);
56
+ }
57
+ return () => {
58
+ observer.disconnect();
59
+ };
60
+ }, [element]);
61
+ if (typeof children === 'function') {
62
+ children = children({
63
+ visible
64
+ });
65
+ }
66
+
67
+ // delete this block on cleanup of media-perf-uplift-mutation-fix
68
+ if (!fg('media-perf-uplift-mutation-fix')) {
69
+ // becuase it is wrapped in a fragment, React.Children.count(children) will always be 1.
70
+ // That makes this check a source of late mutations that we don't need.
71
+ if (!element || React.Children.count(children) === 0) {
72
+ return null;
73
+ }
74
+ }
75
+ return /*#__PURE__*/React.createElement(Box, {
76
+ as: "div",
77
+ testId: "media-badges",
78
+ "data-media-badges": "true",
79
+ contentEditable: false
80
+ // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
81
+ ,
82
+ xcss: [containerStyles, useMinimumZIndex && hackedZIndexStyles, extendedResizeOffset && resizeOffsetStyles]
83
+ }, children);
84
+ };
@@ -4,7 +4,7 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  * @jsx jsx
5
5
  */
6
6
 
7
- import React, { Fragment } from 'react';
7
+ import React, { Fragment, useCallback, useState } from 'react';
8
8
 
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
10
10
  import { css, jsx } from '@emotion/react';
@@ -17,6 +17,7 @@ import { NodeViewContentHole } from '../../../react-node-view/NodeViewContentHol
17
17
  import { overflowShadow } from '../../../ui';
18
18
  import { calculateBreakoutStyles } from '../../../utils';
19
19
  import { shouldExtensionBreakout } from '../../utils/should-extension-breakout';
20
+ import { ExtensionCommentBadge } from '../ExtensionCommentBadge';
20
21
  import ExtensionLozenge from '../Lozenge';
21
22
  import { overlay } from '../styles';
22
23
  import { isEmptyBodiedMacro } from './extension-utils';
@@ -52,6 +53,13 @@ function ExtensionWithPluginState(props) {
52
53
  isLivePageViewMode,
53
54
  hideConfigureLabel
54
55
  } = props;
56
+ const [container, setContainer] = useState(null);
57
+ const handleContainerRef = useCallback(element => {
58
+ handleRef === null || handleRef === void 0 ? void 0 : handleRef(element);
59
+ if (fg('cc_maui_annotations_on_extensions')) {
60
+ setContainer(element);
61
+ }
62
+ }, [handleRef]);
55
63
  const {
56
64
  showMacroInteractionDesignUpdates
57
65
  } = macroInteractionDesignFeatureFlags || {};
@@ -156,7 +164,7 @@ function ExtensionWithPluginState(props) {
156
164
  hideConfigureLabel: hideConfigureLabel
157
165
  }), jsx("div", {
158
166
  "data-testid": "extension-container",
159
- ref: handleRef,
167
+ ref: handleContainerRef,
160
168
  "data-layout": node.attrs.layout
161
169
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
162
170
  ,
@@ -216,7 +224,13 @@ function ExtensionWithPluginState(props) {
216
224
  className: contentClassNames
217
225
  }, jsx(NodeViewContentHole, {
218
226
  ref: handleContentDOMRef
219
- }))))));
227
+ })))), fg('cc_maui_annotations_on_extensions') && node.type.name === 'extension' && container && (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.annotation) && jsx(ExtensionCommentBadge, {
228
+ api: pluginInjectionApi,
229
+ node: node,
230
+ getPos: getPos,
231
+ editorView: view,
232
+ container: container
233
+ })));
220
234
  }
221
235
  const Extension = props => {
222
236
  const {
@@ -0,0 +1,60 @@
1
+ import React, { useCallback, useMemo } from 'react';
2
+ import { VIEW_METHOD } from '../../analytics';
3
+ import { BlockNodeBadges } from '../../block-node-badges';
4
+ import { useSharedPluginStateWithSelector } from '../../hooks';
5
+ import { CommentBadgeNext } from '../../media-single/CommentBadgeNext';
6
+ // Owned by the extension node view, like media's badge. Annotation updates only
7
+ // render this sibling of the extension content; they never reparent its iframe.
8
+ export const ExtensionCommentBadge = ({
9
+ api,
10
+ editorView,
11
+ node,
12
+ getPos,
13
+ container
14
+ }) => {
15
+ var _api$annotation4;
16
+ const {
17
+ annotationState
18
+ } = useSharedPluginStateWithSelector(api, ['annotation'], states => ({
19
+ annotationState: states.annotationState
20
+ }));
21
+ const drafting = Boolean((annotationState === null || annotationState === void 0 ? void 0 : annotationState.isDrafting) && node.attrs.localId && node.attrs.localId === annotationState.targetNodeId);
22
+ const hasOpenDraft = Boolean(annotationState === null || annotationState === void 0 ? void 0 : annotationState.isDrafting);
23
+ const unresolvedIds = useMemo(() => node.marks.filter(mark => mark.type.name === 'annotation' && (annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations[mark.attrs.id]) === false).map(mark => mark.attrs.id), [node.marks, annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations]);
24
+ const onClick = useCallback(async event => {
25
+ var _api$annotation, _api$annotation2;
26
+ event.preventDefault();
27
+ event.stopPropagation();
28
+ if (drafting) {
29
+ return;
30
+ }
31
+ if (hasOpenDraft && !(await (api === null || api === void 0 ? void 0 : (_api$annotation = api.annotation) === null || _api$annotation === void 0 ? void 0 : _api$annotation.actions.requestCloseInlineComment()))) {
32
+ return;
33
+ }
34
+ // Resolve the current position after the asynchronous discard confirmation.
35
+ const pos = getPos();
36
+ if (typeof pos !== 'number' || !Number.isFinite(pos) || pos < 0 || pos >= editorView.state.doc.content.size) {
37
+ return;
38
+ }
39
+ const currentNode = editorView.state.doc.nodeAt(pos);
40
+ if ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.type) === node.type && currentNode.attrs.localId === node.attrs.localId && api !== null && api !== void 0 && (_api$annotation2 = api.annotation) !== null && _api$annotation2 !== void 0 && _api$annotation2.actions.isBlockNodeSupported(currentNode)) {
41
+ var _api$annotation3;
42
+ api === null || api === void 0 ? void 0 : (_api$annotation3 = api.annotation) === null || _api$annotation3 === void 0 ? void 0 : _api$annotation3.actions.showCommentForBlockNode(currentNode, VIEW_METHOD.BADGE)(editorView.state, editorView.dispatch);
43
+ }
44
+ }, [api, editorView, node, getPos, drafting, hasOpenDraft]);
45
+ if (!(annotationState !== null && annotationState !== void 0 && annotationState.isVisible) || node.type.name !== 'extension' || !(api !== null && api !== void 0 && (_api$annotation4 = api.annotation) !== null && _api$annotation4 !== void 0 && _api$annotation4.actions.isBlockNodeSupported(node))) {
46
+ return null;
47
+ }
48
+ if (!drafting && !unresolvedIds.length) {
49
+ return null;
50
+ }
51
+ const active = drafting || !annotationState.isInlineCommentViewClosed && annotationState.selectedAnnotations.some(({
52
+ id
53
+ }) => unresolvedIds.includes(id));
54
+ return /*#__PURE__*/React.createElement(BlockNodeBadges, {
55
+ element: container
56
+ }, /*#__PURE__*/React.createElement(CommentBadgeNext, {
57
+ onClick: onClick,
58
+ status: active ? 'active' : 'default'
59
+ }));
60
+ };
@@ -1,84 +1,17 @@
1
- import React, { useEffect, useState } from 'react';
2
- import debounce from 'lodash/debounce';
3
- import { fg } from '@atlaskit/platform-feature-flags/fg';
4
- // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
5
- import { Box, xcss } from '@atlaskit/primitives';
6
- const MEDIA_BADGE_VISIBILITY_BREAKPOINT = 200;
7
- const containerStyles = xcss({
8
- display: 'flex',
9
- position: 'absolute',
10
- top: 'space.0',
11
- right: 'space.0',
12
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
13
- lineHeight: "var(--ds-space-200, 16px)",
14
- gap: 'space.025',
15
- zIndex: 'card',
16
- height: 'fit-content',
17
- width: 'fit-content',
18
- margin: 'space.075'
19
- });
20
-
21
- // The above styles are used for both editor and renderer, and in renderer the
22
- // document body is the main scroll area. This means it overscrolls the primary
23
- // toolbar, where the z-index is "2". We have to hack in our own z-index less
24
- // than that to ensure our badge appears under the toolbar when scrolled.
25
- const hackedZIndexStyles = xcss({
26
- zIndex: '1'
27
- });
28
- const resizeOffsetStyles = xcss({
29
- right: 'space.150'
30
- });
31
- const getBadgeVisible = (width, height) => {
32
- return width && width < MEDIA_BADGE_VISIBILITY_BREAKPOINT || height && height < MEDIA_BADGE_VISIBILITY_BREAKPOINT ? false : true;
33
- };
1
+ import React from 'react';
2
+ import { BlockNodeBadges } from '../block-node-badges';
3
+ /** Compatibility wrapper for existing media consumers of BlockNodeBadges. */
34
4
  export const MediaBadges = ({
35
- children,
36
5
  mediaElement,
37
6
  mediaWidth,
38
7
  mediaHeight,
8
+ children,
39
9
  extendedResizeOffset,
40
- useMinimumZIndex = false
41
- }) => {
42
- const [visible, setVisible] = useState(getBadgeVisible(mediaWidth, mediaHeight));
43
- useEffect(() => {
44
- const observer = new ResizeObserver(debounce(entries => {
45
- const [entry] = entries;
46
- const {
47
- width,
48
- height
49
- } = entry.contentRect;
50
- setVisible(getBadgeVisible(width, height));
51
- }));
52
- if (mediaElement) {
53
- // Ignored via go/ees005
54
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
55
- observer.observe(mediaElement);
56
- }
57
- return () => {
58
- observer.disconnect();
59
- };
60
- }, [mediaElement]);
61
- if (typeof children === 'function') {
62
- children = children({
63
- visible
64
- });
65
- }
66
-
67
- // delete this block on cleanup of media-perf-uplift-mutation-fix
68
- if (!fg('media-perf-uplift-mutation-fix')) {
69
- // becuase it is wrapped in a fragment, React.Children.count(children) will always be 1.
70
- // That makes this check a source of late mutations that we don't need.
71
- if (!mediaElement || React.Children.count(children) === 0) {
72
- return null;
73
- }
74
- }
75
- return /*#__PURE__*/React.createElement(Box, {
76
- as: "div",
77
- testId: "media-badges",
78
- "data-media-badges": "true",
79
- contentEditable: false
80
- // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
81
- ,
82
- xcss: [containerStyles, useMinimumZIndex && hackedZIndexStyles, extendedResizeOffset && resizeOffsetStyles]
83
- }, children);
84
- };
10
+ useMinimumZIndex
11
+ }) => /*#__PURE__*/React.createElement(BlockNodeBadges, {
12
+ element: mediaElement,
13
+ width: mediaWidth,
14
+ height: mediaHeight,
15
+ extendedResizeOffset: extendedResizeOffset,
16
+ useMinimumZIndex: useMinimumZIndex
17
+ }, children);
@@ -13,7 +13,7 @@ const NETWORK_FAILURE_REGEX = /^network failure/i;
13
13
  const RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
14
14
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
15
15
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
16
- const packageVersion = "128.3.1";
16
+ const packageVersion = "128.3.2";
17
17
  const sanitiseSentryEvents = (data, _hint) => {
18
18
  // Remove URL as it has UGC
19
19
  // Ignored via go/ees007
@@ -5,7 +5,7 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
5
5
  import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../analytics';
6
6
  import { isSSR } from '../core-utils/is-ssr';
7
7
  import { ErrorBoundary } from '../ui/ErrorBoundary';
8
- import { analyticsEventKey, getPerformanceOptions, startMeasureReactNodeViewRendered, stopMeasureReactNodeViewRendered } from '../utils';
8
+ import { analyticsEventKey } from '../utils';
9
9
  import { getBrowserInfo } from '../utils/browser';
10
10
  import { ZERO_WIDTH_SPACE } from '../whitespace';
11
11
  import { generateUniqueNodeKey } from './generateUniqueNodeKey';
@@ -71,23 +71,9 @@ function createNodeView({
71
71
  extraComponentProps
72
72
  }), domRef, key);
73
73
  }
74
- const {
75
- samplingRate,
76
- slowThreshold,
77
- trackingEnabled
78
- } = getPerformanceOptions(nodeViewParams.view);
79
- trackingEnabled && startMeasureReactNodeViewRendered({
80
- nodeTypeName: currentNode.type.name
81
- });
82
74
 
83
75
  // We render the component while creating the node view
84
76
  renderComponent();
85
- trackingEnabled && stopMeasureReactNodeViewRendered({
86
- nodeTypeName: currentNode.type.name,
87
- dispatchAnalyticsEvent,
88
- samplingRate,
89
- slowThreshold
90
- });
91
77
  const extraNodeViewPropsWithStopEvent = {
92
78
  ...extraNodeViewProps
93
79
  };
@@ -8,7 +8,6 @@ import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../analytics';
8
8
  import { isSSR } from '../core-utils';
9
9
  import { createDispatch } from '../event-dispatcher';
10
10
  import { ErrorBoundary } from '../ui/ErrorBoundary';
11
- import { getPerformanceOptions, startMeasureReactNodeViewRendered, stopMeasureReactNodeViewRendered } from '../utils';
12
11
  import { analyticsEventKey } from '../utils/analytics';
13
12
  import { generateUniqueNodeKey } from './generateUniqueNodeKey';
14
13
  export { getInlineNodeViewProducer, inlineNodeViewClassname } from './getInlineNodeViewProducer';
@@ -79,14 +78,6 @@ export default class ReactNodeView {
79
78
  // nodeView if DOM structure has nested plain "div"s, it doesn't see the
80
79
  // difference between them and it kills the nodeView
81
80
  this.domRef.classList.add(`${this.node.type.name}View-content-wrap`);
82
- const {
83
- samplingRate,
84
- slowThreshold,
85
- trackingEnabled
86
- } = getPerformanceOptions(this.view);
87
- trackingEnabled && startMeasureReactNodeViewRendered({
88
- nodeTypeName: this.node.type.name
89
- });
90
81
  if (!shouldSkipInitRender) {
91
82
  this.renderReactComponent(() => this.render(this.reactComponentProps, this.handleRef));
92
83
 
@@ -105,12 +96,6 @@ export default class ReactNodeView {
105
96
  }
106
97
  }
107
98
  }
108
- trackingEnabled && stopMeasureReactNodeViewRendered({
109
- nodeTypeName: this.node.type.name,
110
- dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
111
- samplingRate,
112
- slowThreshold
113
- });
114
99
  return this;
115
100
  }
116
101
 
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import { fg } from '@atlaskit/platform-feature-flags/fg';
15
15
  import Layer from '../Layer';
16
16
  const packageName = "@atlaskit/editor-common";
17
- const packageVersion = "128.3.1";
17
+ const packageVersion = "128.3.2";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -86,9 +86,6 @@ getDistortedDurationMonitor,
86
86
  */
87
87
  measureRender } from './performance/measure-render';
88
88
  export { startMeasure, stopMeasure, clearMeasure } from './performance/measure';
89
- export { TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS } from './performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS';
90
- export { TTI_SEVERITY_THRESHOLD_DEFAULTS } from './performance/TTI_SEVERITY_THRESHOLD_DEFAULTS';
91
- export { measureTTI, getTTISeverity } from './performance/measure-tti';
92
89
  /**
93
90
  * @private
94
91
  * @deprecated
@@ -121,8 +118,6 @@ export { isTextInput } from './is-text-input';
121
118
  export { ZERO_WIDTH_SPACE, ZERO_WIDTH_JOINER } from '../whitespace';
122
119
  export { shouldForceTracking } from './should-force-tracking';
123
120
  export { getModeFromTheme } from './getModeFromTheme';
124
- export { getPerformanceOptions, stopMeasureReactNodeViewRendered } from './get-performance-options';
125
- export { startMeasureReactNodeViewRendered } from './startMeasureReactNodeViewRendered';
126
121
  export { sniffUserBrowserExtensions } from './browser-extensions';
127
122
  export { RenderCountProfiler, PROFILER_KEY } from './profiler/render-count';
128
123
  export { validateADFEntity, validationErrorHandler } from './validate-using-spec';
@@ -50,14 +50,12 @@ export var ACTION = /*#__PURE__*/function (ACTION) {
50
50
  ACTION["DISPLAYED"] = "displayed";
51
51
  ACTION["DIVERGED"] = "diverged";
52
52
  ACTION["DISPATCHED_INVALID_TRANSACTION"] = "dispatchedInvalidTransaction";
53
- ACTION["DISPATCHED_VALID_TRANSACTION"] = "dispatchedValidTransaction";
54
53
  ACTION["DOUBLE_CLICKED"] = "doubleClicked";
55
54
  ACTION["DRAGGED"] = "dragged";
56
55
  ACTION["EDITED"] = "edited";
57
56
  ACTION["EDITOR_CRASHED"] = "unhandledErrorCaught";
58
57
  ACTION["EDITOR_CRASHED_ADDITIONAL_INFORMATION"] = "unhandledErrorCaughtAdditionalInfov2";
59
58
  ACTION["EDITOR_MOUNTED"] = "mounted";
60
- ACTION["EDITOR_CONTENT_RETRIEVAL_PERFORMED"] = "contentRetrievalPerformed";
61
59
  ACTION["RE_RENDERED"] = "reRendered";
62
60
  ACTION["ENDED"] = "ended";
63
61
  ACTION["ENTERED"] = "entered";
@@ -116,7 +114,6 @@ export var ACTION = /*#__PURE__*/function (ACTION) {
116
114
  ACTION["PRESSED"] = "pressed";
117
115
  ACTION["QUICK_INSERT_INFORMATION"] = "quickInsertInformation";
118
116
  ACTION["PROSEMIRROR_RENDERED"] = "proseMirrorRendered";
119
- ACTION["REACT_NODEVIEW_RENDERED"] = "reactNodeViewRendered";
120
117
  ACTION["REFERENCE_SYNCED_BLOCK_DELETE"] = "referenceSyncedBlockDelete";
121
118
  ACTION["REFERENCE_SYNCED_BLOCK_UPDATE"] = "referenceSyncedBlockUpdate";
122
119
  ACTION["REFERENCE_SYNCED_BLOCK_UNSYNC"] = "referenceSyncedBlockUnsync";
@@ -172,18 +169,9 @@ export var ACTION = /*#__PURE__*/function (ACTION) {
172
169
  ACTION["UPLOAD_EXTERNAL_FAIL"] = "uploadExternalFailed";
173
170
  ACTION["VIEWED"] = "viewed";
174
171
  ACTION["VISITED"] = "visited";
175
- ACTION["WITH_PLUGIN_STATE_CALLED"] = "withPluginStateCalled";
176
172
  ACTION["RENDERED"] = "rendered";
177
- ACTION["RENDERED_SAMPLED"] = "renderedSampled";
178
173
  ACTION["REASONING_VIEWED"] = "reasoningViewed";
179
174
  ACTION["ON_EDITOR_READY_CALLBACK"] = "onEditorReadyCallback";
180
- /**
181
- * @private
182
- * @deprecated
183
- *
184
- * This is no longer used and can be removed at a later date
185
- */
186
- ACTION["ON_CHANGE_CALLBACK"] = "onChangeCalled";
187
175
  ACTION["NESTED_TABLE_TRANSFORMED"] = "nestedTableTransformed";
188
176
  ACTION["CONTAINER_NODE_TRANSFORMED"] = "containerNodeTransformed";
189
177
  ACTION["NATIVE_EMBEDS_TRANSFORMED"] = "nativeEmbedsTransformed";
@@ -0,0 +1,88 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useEffect, useState } from 'react';
3
+ import debounce from 'lodash/debounce';
4
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
5
+ // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
6
+ import { Box, xcss } from '@atlaskit/primitives';
7
+ var BADGE_VISIBILITY_BREAKPOINT = 200;
8
+ var containerStyles = xcss({
9
+ display: 'flex',
10
+ position: 'absolute',
11
+ top: 'space.0',
12
+ right: 'space.0',
13
+ // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
14
+ lineHeight: "var(--ds-space-200, 16px)",
15
+ gap: 'space.025',
16
+ zIndex: 'card',
17
+ height: 'fit-content',
18
+ width: 'fit-content',
19
+ margin: 'space.075'
20
+ });
21
+
22
+ // The above styles are used for both editor and renderer, and in renderer the
23
+ // document body is the main scroll area. This means it overscrolls the primary
24
+ // toolbar, where the z-index is "2". We have to hack in our own z-index less
25
+ // than that to ensure our badge appears under the toolbar when scrolled.
26
+ var hackedZIndexStyles = xcss({
27
+ zIndex: '1'
28
+ });
29
+ var resizeOffsetStyles = xcss({
30
+ right: 'space.150'
31
+ });
32
+ var getBadgeVisible = function getBadgeVisible(width, height) {
33
+ return width && width < BADGE_VISIBILITY_BREAKPOINT || height && height < BADGE_VISIBILITY_BREAKPOINT ? false : true;
34
+ };
35
+ export var BlockNodeBadges = function BlockNodeBadges(_ref) {
36
+ var children = _ref.children,
37
+ element = _ref.element,
38
+ width = _ref.width,
39
+ height = _ref.height,
40
+ extendedResizeOffset = _ref.extendedResizeOffset,
41
+ _ref$useMinimumZIndex = _ref.useMinimumZIndex,
42
+ useMinimumZIndex = _ref$useMinimumZIndex === void 0 ? false : _ref$useMinimumZIndex;
43
+ var _useState = useState(getBadgeVisible(width, height)),
44
+ _useState2 = _slicedToArray(_useState, 2),
45
+ visible = _useState2[0],
46
+ setVisible = _useState2[1];
47
+ useEffect(function () {
48
+ var observer = new ResizeObserver(debounce(function (entries) {
49
+ var _entries = _slicedToArray(entries, 1),
50
+ entry = _entries[0];
51
+ var _entry$contentRect = entry.contentRect,
52
+ width = _entry$contentRect.width,
53
+ height = _entry$contentRect.height;
54
+ setVisible(getBadgeVisible(width, height));
55
+ }));
56
+ if (element) {
57
+ // Ignored via go/ees005
58
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
59
+ observer.observe(element);
60
+ }
61
+ return function () {
62
+ observer.disconnect();
63
+ };
64
+ }, [element]);
65
+ if (typeof children === 'function') {
66
+ children = children({
67
+ visible: visible
68
+ });
69
+ }
70
+
71
+ // delete this block on cleanup of media-perf-uplift-mutation-fix
72
+ if (!fg('media-perf-uplift-mutation-fix')) {
73
+ // becuase it is wrapped in a fragment, React.Children.count(children) will always be 1.
74
+ // That makes this check a source of late mutations that we don't need.
75
+ if (!element || React.Children.count(children) === 0) {
76
+ return null;
77
+ }
78
+ }
79
+ return /*#__PURE__*/React.createElement(Box, {
80
+ as: "div",
81
+ testId: "media-badges",
82
+ "data-media-badges": "true",
83
+ contentEditable: false
84
+ // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
85
+ ,
86
+ xcss: [containerStyles, useMinimumZIndex && hackedZIndexStyles, extendedResizeOffset && resizeOffsetStyles]
87
+ }, children);
88
+ };
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
5
  var _excluded = ["type"];
5
6
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -9,7 +10,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
9
10
  * @jsx jsx
10
11
  */
11
12
 
12
- import React, { Fragment } from 'react';
13
+ import React, { Fragment, useCallback, useState } from 'react';
13
14
 
14
15
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
15
16
  import { css, jsx } from '@emotion/react';
@@ -22,6 +23,7 @@ import { NodeViewContentHole } from '../../../react-node-view/NodeViewContentHol
22
23
  import { overflowShadow } from '../../../ui';
23
24
  import { calculateBreakoutStyles } from '../../../utils';
24
25
  import { shouldExtensionBreakout } from '../../utils/should-extension-breakout';
26
+ import { ExtensionCommentBadge } from '../ExtensionCommentBadge';
25
27
  import ExtensionLozenge from '../Lozenge';
26
28
  import { overlay } from '../styles';
27
29
  import { isEmptyBodiedMacro } from './extension-utils';
@@ -55,6 +57,16 @@ function ExtensionWithPluginState(props) {
55
57
  pluginInjectionApi = props.pluginInjectionApi,
56
58
  isLivePageViewMode = props.isLivePageViewMode,
57
59
  hideConfigureLabel = props.hideConfigureLabel;
60
+ var _useState = useState(null),
61
+ _useState2 = _slicedToArray(_useState, 2),
62
+ container = _useState2[0],
63
+ setContainer = _useState2[1];
64
+ var handleContainerRef = useCallback(function (element) {
65
+ handleRef === null || handleRef === void 0 || handleRef(element);
66
+ if (fg('cc_maui_annotations_on_extensions')) {
67
+ setContainer(element);
68
+ }
69
+ }, [handleRef]);
58
70
  var _ref = macroInteractionDesignFeatureFlags || {},
59
71
  showMacroInteractionDesignUpdates = _ref.showMacroInteractionDesignUpdates;
60
72
  var isLegacyContentMacroExtension = function isLegacyContentMacroExtension(extensionNode) {
@@ -149,7 +161,7 @@ function ExtensionWithPluginState(props) {
149
161
  hideConfigureLabel: hideConfigureLabel
150
162
  }), jsx("div", {
151
163
  "data-testid": "extension-container",
152
- ref: handleRef,
164
+ ref: handleContainerRef,
153
165
  "data-layout": node.attrs.layout
154
166
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
155
167
  ,
@@ -213,7 +225,13 @@ function ExtensionWithPluginState(props) {
213
225
  className: contentClassNames
214
226
  }, jsx(NodeViewContentHole, {
215
227
  ref: handleContentDOMRef
216
- }))))));
228
+ })))), fg('cc_maui_annotations_on_extensions') && node.type.name === 'extension' && container && (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.annotation) && jsx(ExtensionCommentBadge, {
229
+ api: pluginInjectionApi,
230
+ node: node,
231
+ getPos: getPos,
232
+ editorView: view,
233
+ container: container
234
+ })));
217
235
  }
218
236
  var Extension = function Extension(props) {
219
237
  var pluginInjectionApi = props.pluginInjectionApi;