@atlaskit/editor-common 128.3.1 → 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 (83) hide show
  1. package/CHANGELOG.md +41 -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/element-browser/components/ElementList/ElementList.js +2 -3
  6. package/dist/cjs/element-browser/components/StatelessElementBrowser.js +2 -2
  7. package/dist/cjs/extensibility/Extension/Extension/index.js +20 -2
  8. package/dist/cjs/extensibility/Extension/ExtensionCommentBadge.js +110 -0
  9. package/dist/cjs/extensibility/MultiBodiedExtension/index.js +4 -21
  10. package/dist/cjs/media-single/MediaBadges.js +12 -85
  11. package/dist/cjs/monitoring/error.js +1 -1
  12. package/dist/cjs/react-node-view/getInlineNodeViewProducer.js +0 -13
  13. package/dist/cjs/react-node-view/index.js +0 -14
  14. package/dist/cjs/ui/DropList/index.js +1 -1
  15. package/dist/cjs/ui-menu/DropdownMenu/index.js +4 -6
  16. package/dist/cjs/utils/index.js +0 -47
  17. package/dist/es2019/analytics/types/enums.js +0 -12
  18. package/dist/es2019/block-node-badges.js +84 -0
  19. package/dist/es2019/element-browser/components/ElementList/ElementList.js +2 -3
  20. package/dist/es2019/element-browser/components/StatelessElementBrowser.js +2 -2
  21. package/dist/es2019/extensibility/Extension/Extension/index.js +17 -3
  22. package/dist/es2019/extensibility/Extension/ExtensionCommentBadge.js +60 -0
  23. package/dist/es2019/extensibility/MultiBodiedExtension/index.js +4 -24
  24. package/dist/es2019/media-single/MediaBadges.js +12 -79
  25. package/dist/es2019/monitoring/error.js +1 -1
  26. package/dist/es2019/react-node-view/getInlineNodeViewProducer.js +1 -15
  27. package/dist/es2019/react-node-view/index.js +0 -15
  28. package/dist/es2019/ui/DropList/index.js +1 -1
  29. package/dist/es2019/ui-menu/DropdownMenu/index.js +4 -6
  30. package/dist/es2019/utils/index.js +0 -5
  31. package/dist/esm/analytics/types/enums.js +0 -12
  32. package/dist/esm/block-node-badges.js +88 -0
  33. package/dist/esm/element-browser/components/ElementList/ElementList.js +2 -3
  34. package/dist/esm/element-browser/components/StatelessElementBrowser.js +2 -2
  35. package/dist/esm/extensibility/Extension/Extension/index.js +21 -3
  36. package/dist/esm/extensibility/Extension/ExtensionCommentBadge.js +101 -0
  37. package/dist/esm/extensibility/MultiBodiedExtension/index.js +4 -21
  38. package/dist/esm/media-single/MediaBadges.js +12 -82
  39. package/dist/esm/monitoring/error.js +1 -1
  40. package/dist/esm/react-node-view/getInlineNodeViewProducer.js +1 -14
  41. package/dist/esm/react-node-view/index.js +0 -14
  42. package/dist/esm/ui/DropList/index.js +1 -1
  43. package/dist/esm/ui-menu/DropdownMenu/index.js +4 -6
  44. package/dist/esm/utils/index.js +0 -5
  45. package/dist/types/analytics/index.d.ts +1 -2
  46. package/dist/types/analytics/types/enums.d.ts +0 -12
  47. package/dist/types/analytics/types/events.d.ts +1 -3
  48. package/dist/types/analytics/types/general-events.d.ts +2 -15
  49. package/dist/types/block-node-badges.d.ts +14 -0
  50. package/dist/types/extensibility/Extension/ExtensionCommentBadge.d.ts +8 -0
  51. package/dist/types/extensibility/types.d.ts +29 -2
  52. package/dist/types/media-single/MediaBadges.d.ts +4 -8
  53. package/dist/types/types/index.d.ts +1 -1
  54. package/dist/types/types/performance-tracking.d.ts +0 -22
  55. package/dist/types/utils/index.d.ts +0 -5
  56. package/package.json +6 -5
  57. package/analytics/types/performance-report/package.json +0 -10
  58. package/dist/cjs/analytics/types/performance-report.js +0 -1
  59. package/dist/cjs/utils/get-performance-options.js +0 -65
  60. package/dist/cjs/utils/performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.js +0 -10
  61. package/dist/cjs/utils/performance/TTI_SEVERITY_THRESHOLD_DEFAULTS.js +0 -10
  62. package/dist/cjs/utils/performance/measure-tti.js +0 -112
  63. package/dist/cjs/utils/startMeasureReactNodeViewRendered.js +0 -11
  64. package/dist/es2019/analytics/types/performance-report.js +0 -0
  65. package/dist/es2019/utils/get-performance-options.js +0 -54
  66. package/dist/es2019/utils/performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.js +0 -4
  67. package/dist/es2019/utils/performance/TTI_SEVERITY_THRESHOLD_DEFAULTS.js +0 -4
  68. package/dist/es2019/utils/performance/measure-tti.js +0 -91
  69. package/dist/es2019/utils/startMeasureReactNodeViewRendered.js +0 -6
  70. package/dist/esm/analytics/types/performance-report.js +0 -0
  71. package/dist/esm/utils/get-performance-options.js +0 -53
  72. package/dist/esm/utils/performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.js +0 -4
  73. package/dist/esm/utils/performance/TTI_SEVERITY_THRESHOLD_DEFAULTS.js +0 -4
  74. package/dist/esm/utils/performance/measure-tti.js +0 -94
  75. package/dist/esm/utils/startMeasureReactNodeViewRendered.js +0 -5
  76. package/dist/types/analytics/types/performance-report.d.ts +0 -24
  77. package/dist/types/utils/get-performance-options.d.ts +0 -14
  78. package/dist/types/utils/performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.d.ts +0 -4
  79. package/dist/types/utils/performance/TTI_SEVERITY_THRESHOLD_DEFAULTS.d.ts +0 -4
  80. package/dist/types/utils/performance/measure-tti.d.ts +0 -8
  81. package/dist/types/utils/startMeasureReactNodeViewRendered.d.ts +0 -3
  82. package/performance/measure-tti/package.json +0 -10
  83. package/utils/get-performance-options/package.json +0 -10
@@ -16,7 +16,6 @@ import MenuGroup from '@atlaskit/menu/menu-group';
16
16
  import Section from '@atlaskit/menu/section';
17
17
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
18
18
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
19
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
20
19
  import Tooltip from '@atlaskit/tooltip/Tooltip';
21
20
  import { DropdownMenuSharedCssClassName } from '../../styles';
22
21
  import { KeyDownHandlerContext } from '../../ui-menu/ToolbarArrowKeyNavigationProvider';
@@ -377,16 +376,16 @@ export function DropdownMenuItem({
377
376
  const tabIndex = item.wrapperTabIndex === null ? undefined : item.wrapperTabIndex || -1;
378
377
  const dropListItem = jsx("div", {
379
378
  css: () => buttonStyles(item.isActive, submenuActive),
380
- role: expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? shouldUseDefaultRole ? undefined : 'menuitem' : undefined,
379
+ role: shouldUseDefaultRole ? undefined : 'menuitem',
381
380
  tabIndex: tabIndex,
382
381
  "aria-disabled": item.isDisabled ? 'true' : 'false',
383
- "aria-expanded": expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? item['aria-expanded'] : undefined,
382
+ "aria-expanded": item['aria-expanded'],
384
383
  onMouseDown: _handleSubmenuActive
385
384
  }, jsx(CustomItem, {
386
385
  item: item,
387
386
  key: (_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : String(item.content),
388
387
  testId: testId,
389
- role: shouldUseDefaultRole ? 'button' : expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? undefined : 'menuitem',
388
+ role: shouldUseDefaultRole ? 'button' : undefined,
390
389
  iconBefore: item.elemBefore,
391
390
  iconAfter: item.elemAfter,
392
391
  isDisabled: item.isDisabled,
@@ -397,8 +396,7 @@ export function DropdownMenuItem({
397
396
  onMouseDown: onMouseDown,
398
397
  component: DropdownMenuItemCustomComponent,
399
398
  onMouseEnter: onMouseEnterHandler,
400
- onMouseLeave: onMouseLeaveHandler,
401
- "aria-expanded": expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? undefined : item['aria-expanded']
399
+ onMouseLeave: onMouseLeaveHandler
402
400
  }, item.content));
403
401
  if (item.tooltipDescription) {
404
402
  var _item$key3;
@@ -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
+ };
@@ -233,7 +233,7 @@ var ElementListSingleColumn = function ElementListSingleColumn(props) {
233
233
  focus: focusedItemIndex === index,
234
234
  setFocusedItemIndex: setFocusedItemIndex,
235
235
  onInsertItem: onInsertItem,
236
- role: expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? 'option' : undefined
236
+ role: "option"
237
237
  })));
238
238
  };
239
239
  },
@@ -417,8 +417,7 @@ export function ElementItem(_ref6) {
417
417
  title: title
418
418
  }),
419
419
  isSelected: selected,
420
- "aria-describedby": expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? undefined : title,
421
- "aria-label": expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? title : undefined,
420
+ "aria-label": title,
422
421
  ref: ref,
423
422
  testId: "element-item-".concat(index),
424
423
  id: "searched-item-".concat(index),
@@ -341,7 +341,7 @@ function MobileBrowser(_ref) {
341
341
  searchTerm: searchTerm,
342
342
  items: items,
343
343
  selectedItemIndex: selectedItemIndex,
344
- ariaControlsId: expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? ELEMENT_BROWSER_LIST_ID : undefined
344
+ ariaControlsId: ELEMENT_BROWSER_LIST_ID
345
345
  }), showCategories && jsx("nav", {
346
346
  css: mobileCategoryListWrapper,
347
347
  tabIndex: -1
@@ -355,7 +355,7 @@ function MobileBrowser(_ref) {
355
355
  setFocusOnSearch: setFocusOnSearch
356
356
  }))), jsx("div", {
357
357
  css: mobileMainContent,
358
- id: expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? ELEMENT_BROWSER_LIST_ID : undefined
358
+ id: ELEMENT_BROWSER_LIST_ID
359
359
  }, jsx(ElementList, {
360
360
  items: items,
361
361
  mode: mode,
@@ -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;
@@ -0,0 +1,101 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import React, { useCallback, useMemo } from 'react';
4
+ import { VIEW_METHOD } from '../../analytics';
5
+ import { BlockNodeBadges } from '../../block-node-badges';
6
+ import { useSharedPluginStateWithSelector } from '../../hooks';
7
+ import { CommentBadgeNext } from '../../media-single/CommentBadgeNext';
8
+ // Owned by the extension node view, like media's badge. Annotation updates only
9
+ // render this sibling of the extension content; they never reparent its iframe.
10
+ export var ExtensionCommentBadge = function ExtensionCommentBadge(_ref) {
11
+ var _api$annotation4;
12
+ var api = _ref.api,
13
+ editorView = _ref.editorView,
14
+ node = _ref.node,
15
+ getPos = _ref.getPos,
16
+ container = _ref.container;
17
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['annotation'], function (states) {
18
+ return {
19
+ annotationState: states.annotationState
20
+ };
21
+ }),
22
+ annotationState = _useSharedPluginState.annotationState;
23
+ var drafting = Boolean((annotationState === null || annotationState === void 0 ? void 0 : annotationState.isDrafting) && node.attrs.localId && node.attrs.localId === annotationState.targetNodeId);
24
+ var hasOpenDraft = Boolean(annotationState === null || annotationState === void 0 ? void 0 : annotationState.isDrafting);
25
+ var unresolvedIds = useMemo(function () {
26
+ return node.marks.filter(function (mark) {
27
+ return mark.type.name === 'annotation' && (annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations[mark.attrs.id]) === false;
28
+ }).map(function (mark) {
29
+ return mark.attrs.id;
30
+ });
31
+ }, [node.marks, annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations]);
32
+ var onClick = useCallback( /*#__PURE__*/function () {
33
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
34
+ var _api$annotation, _api$annotation2;
35
+ var pos, currentNode, _api$annotation3, _t;
36
+ return _regeneratorRuntime.wrap(function (_context) {
37
+ while (1) switch (_context.prev = _context.next) {
38
+ case 0:
39
+ event.preventDefault();
40
+ event.stopPropagation();
41
+ if (!drafting) {
42
+ _context.next = 1;
43
+ break;
44
+ }
45
+ return _context.abrupt("return");
46
+ case 1:
47
+ _t = hasOpenDraft;
48
+ if (!_t) {
49
+ _context.next = 3;
50
+ break;
51
+ }
52
+ _context.next = 2;
53
+ return api === null || api === void 0 || (_api$annotation = api.annotation) === null || _api$annotation === void 0 ? void 0 : _api$annotation.actions.requestCloseInlineComment();
54
+ case 2:
55
+ _t = !_context.sent;
56
+ case 3:
57
+ if (!_t) {
58
+ _context.next = 4;
59
+ break;
60
+ }
61
+ return _context.abrupt("return");
62
+ case 4:
63
+ // Resolve the current position after the asynchronous discard confirmation.
64
+ pos = getPos();
65
+ if (!(typeof pos !== 'number' || !Number.isFinite(pos) || pos < 0 || pos >= editorView.state.doc.content.size)) {
66
+ _context.next = 5;
67
+ break;
68
+ }
69
+ return _context.abrupt("return");
70
+ case 5:
71
+ currentNode = editorView.state.doc.nodeAt(pos);
72
+ 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)) {
73
+ api === null || api === void 0 || (_api$annotation3 = api.annotation) === null || _api$annotation3 === void 0 || _api$annotation3.actions.showCommentForBlockNode(currentNode, VIEW_METHOD.BADGE)(editorView.state, editorView.dispatch);
74
+ }
75
+ case 6:
76
+ case "end":
77
+ return _context.stop();
78
+ }
79
+ }, _callee);
80
+ }));
81
+ return function (_x) {
82
+ return _ref2.apply(this, arguments);
83
+ };
84
+ }(), [api, editorView, node, getPos, drafting, hasOpenDraft]);
85
+ 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))) {
86
+ return null;
87
+ }
88
+ if (!drafting && !unresolvedIds.length) {
89
+ return null;
90
+ }
91
+ var active = drafting || !annotationState.isInlineCommentViewClosed && annotationState.selectedAnnotations.some(function (_ref3) {
92
+ var id = _ref3.id;
93
+ return unresolvedIds.includes(id);
94
+ });
95
+ return /*#__PURE__*/React.createElement(BlockNodeBadges, {
96
+ element: container
97
+ }, /*#__PURE__*/React.createElement(CommentBadgeNext, {
98
+ onClick: onClick,
99
+ status: active ? 'active' : 'default'
100
+ }));
101
+ };
@@ -19,7 +19,6 @@ import classnames from 'classnames';
19
19
  import { useIntl } from 'react-intl';
20
20
  import EditorFileIcon from '@atlaskit/icon/core/file';
21
21
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
22
- import { fg } from '@atlaskit/platform-feature-flags/fg';
23
22
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
24
23
  import { useSharedPluginStateWithSelector } from '../../hooks';
25
24
  import { placeholderTextMessages } from '../../messages/placeholder-text';
@@ -30,23 +29,7 @@ import { ExtensionFloatingLabel } from '../Extension/Lozenge/ExtensionFloatingLa
30
29
  import { shouldExtensionBreakout } from '../utils/should-extension-breakout';
31
30
  import { useMultiBodiedExtensionActions } from './action-api';
32
31
  import { mbeExtensionWrapperCSSStyles, mbeExtensionWrapperCSSStylesOld, overlayStyles, overlayStylesOld } from './styles';
33
- var getContainerCssExtendedStyles = function getContainerCssExtendedStyles(activeChildIndex, showMacroInteractionDesignUpdates) {
34
- if (fg('platform_editor_nested_mbe_frames')) {
35
- return sharedMultiBodiedExtensionStyles.mbeExtensionContainer;
36
- }
37
- var activeFrameSelector = ".multiBodiedExtension-content-dom-wrapper > [data-extension-frame='true']:nth-of-type(".concat(activeChildIndex + 1, ")");
38
-
39
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
40
- return css(sharedMultiBodiedExtensionStyles.mbeExtensionContainer, _defineProperty({}, activeFrameSelector, css(
41
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
42
- sharedMultiBodiedExtensionStyles.extensionFrameContent,
43
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
44
- showMacroInteractionDesignUpdates && removeMarginsAndBorder)));
45
- };
46
32
  var getFramesActiveFrameStyles = function getFramesActiveFrameStyles(activeChildIndex, showMacroInteractionDesignUpdates) {
47
- if (!fg('platform_editor_nested_mbe_frames')) {
48
- return undefined;
49
- }
50
33
  var activeFrameSelector = "& > .multiBodiedExtension-content-dom-wrapper > [data-extension-frame='true']:nth-of-type(".concat(activeChildIndex + 1, ")");
51
34
  return css(_defineProperty({}, activeFrameSelector, css(
52
35
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
@@ -353,10 +336,10 @@ var MultiBodiedExtensionWithWidth = function MultiBodiedExtensionWithWidth(_ref2
353
336
  "data-testid": "multiBodiedExtension--overlay"
354
337
  }), getWrapperTitleContent(imageData, title, showMacroInteractionDesignUpdates), jsx("div", {
355
338
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
356
- className: containerClassNames,
357
- css: [/* eslint-disable @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766 */
358
- getContainerCssExtendedStyles(activeChildIndex, showMacroInteractionDesignUpdates)
359
- /* eslint-enable @atlaskit/design-system/consistent-css-prop-usage */],
339
+ className: containerClassNames
340
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
341
+ ,
342
+ css: sharedMultiBodiedExtensionStyles.mbeExtensionContainer,
360
343
  "data-testid": "multiBodiedExtension--container",
361
344
  "data-multiBodiedExtension-container": true,
362
345
  "data-active-child-index": activeChildIndex
@@ -1,88 +1,18 @@
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 MEDIA_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 < MEDIA_BADGE_VISIBILITY_BREAKPOINT || height && height < MEDIA_BADGE_VISIBILITY_BREAKPOINT ? false : true;
34
- };
1
+ import React from 'react';
2
+ import { BlockNodeBadges } from '../block-node-badges';
3
+ /** Compatibility wrapper for existing media consumers of BlockNodeBadges. */
35
4
  export var MediaBadges = function MediaBadges(_ref) {
36
- var children = _ref.children,
37
- mediaElement = _ref.mediaElement,
5
+ var mediaElement = _ref.mediaElement,
38
6
  mediaWidth = _ref.mediaWidth,
39
7
  mediaHeight = _ref.mediaHeight,
8
+ children = _ref.children,
40
9
  extendedResizeOffset = _ref.extendedResizeOffset,
41
- _ref$useMinimumZIndex = _ref.useMinimumZIndex,
42
- useMinimumZIndex = _ref$useMinimumZIndex === void 0 ? false : _ref$useMinimumZIndex;
43
- var _useState = useState(getBadgeVisible(mediaWidth, mediaHeight)),
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 (mediaElement) {
57
- // Ignored via go/ees005
58
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
59
- observer.observe(mediaElement);
60
- }
61
- return function () {
62
- observer.disconnect();
63
- };
64
- }, [mediaElement]);
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 (!mediaElement || 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]
10
+ useMinimumZIndex = _ref.useMinimumZIndex;
11
+ return /*#__PURE__*/React.createElement(BlockNodeBadges, {
12
+ element: mediaElement,
13
+ width: mediaWidth,
14
+ height: mediaHeight,
15
+ extendedResizeOffset: extendedResizeOffset,
16
+ useMinimumZIndex: useMinimumZIndex
87
17
  }, children);
88
18
  };
@@ -19,7 +19,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
19
19
  var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
20
20
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
21
21
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
22
- var packageVersion = "128.3.0";
22
+ var packageVersion = "128.3.2";
23
23
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
24
24
  // Remove URL as it has UGC
25
25
  // Ignored via go/ees007
@@ -8,7 +8,7 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
8
8
  import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../analytics';
9
9
  import { isSSR } from '../core-utils/is-ssr';
10
10
  import { ErrorBoundary } from '../ui/ErrorBoundary';
11
- import { analyticsEventKey, getPerformanceOptions, startMeasureReactNodeViewRendered, stopMeasureReactNodeViewRendered } from '../utils';
11
+ import { analyticsEventKey } from '../utils';
12
12
  import { getBrowserInfo } from '../utils/browser';
13
13
  import { ZERO_WIDTH_SPACE } from '../whitespace';
14
14
  import { generateUniqueNodeKey } from './generateUniqueNodeKey';
@@ -73,22 +73,9 @@ function createNodeView(_ref) {
73
73
  extraComponentProps: extraComponentProps
74
74
  }), domRef, key);
75
75
  }
76
- var _getPerformanceOption = getPerformanceOptions(nodeViewParams.view),
77
- samplingRate = _getPerformanceOption.samplingRate,
78
- slowThreshold = _getPerformanceOption.slowThreshold,
79
- trackingEnabled = _getPerformanceOption.trackingEnabled;
80
- trackingEnabled && startMeasureReactNodeViewRendered({
81
- nodeTypeName: currentNode.type.name
82
- });
83
76
 
84
77
  // We render the component while creating the node view
85
78
  renderComponent();
86
- trackingEnabled && stopMeasureReactNodeViewRendered({
87
- nodeTypeName: currentNode.type.name,
88
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
89
- samplingRate: samplingRate,
90
- slowThreshold: slowThreshold
91
- });
92
79
  var extraNodeViewPropsWithStopEvent = _objectSpread({}, extraNodeViewProps);
93
80
 
94
81
  // https://prosemirror.net/docs/ref/#view.NodeView
@@ -10,7 +10,6 @@ import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../analytics';
10
10
  import { isSSR } from '../core-utils';
11
11
  import { createDispatch } from '../event-dispatcher';
12
12
  import { ErrorBoundary } from '../ui/ErrorBoundary';
13
- import { getPerformanceOptions, startMeasureReactNodeViewRendered, stopMeasureReactNodeViewRendered } from '../utils';
14
13
  import { analyticsEventKey } from '../utils/analytics';
15
14
  import { generateUniqueNodeKey } from './generateUniqueNodeKey';
16
15
  export { getInlineNodeViewProducer, inlineNodeViewClassname } from './getInlineNodeViewProducer';
@@ -88,13 +87,6 @@ var ReactNodeView = /*#__PURE__*/function () {
88
87
  // nodeView if DOM structure has nested plain "div"s, it doesn't see the
89
88
  // difference between them and it kills the nodeView
90
89
  this.domRef.classList.add("".concat(this.node.type.name, "View-content-wrap"));
91
- var _getPerformanceOption = getPerformanceOptions(this.view),
92
- samplingRate = _getPerformanceOption.samplingRate,
93
- slowThreshold = _getPerformanceOption.slowThreshold,
94
- trackingEnabled = _getPerformanceOption.trackingEnabled;
95
- trackingEnabled && startMeasureReactNodeViewRendered({
96
- nodeTypeName: this.node.type.name
97
- });
98
90
  if (!shouldSkipInitRender) {
99
91
  this.renderReactComponent(function () {
100
92
  return _this2.render(_this2.reactComponentProps, _this2.handleRef);
@@ -115,12 +107,6 @@ var ReactNodeView = /*#__PURE__*/function () {
115
107
  }
116
108
  }
117
109
  }
118
- trackingEnabled && stopMeasureReactNodeViewRendered({
119
- nodeTypeName: this.node.type.name,
120
- dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
121
- samplingRate: samplingRate,
122
- slowThreshold: slowThreshold
123
- });
124
110
  return this;
125
111
  }
126
112
 
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import { fg } from '@atlaskit/platform-feature-flags/fg';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "128.3.0";
24
+ var packageVersion = "128.3.2";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({