@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
@@ -26,7 +26,6 @@ var _menuGroup = _interopRequireDefault(require("@atlaskit/menu/menu-group"));
26
26
  var _section = _interopRequireDefault(require("@atlaskit/menu/section"));
27
27
  var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
28
28
  var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
29
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
30
29
  var _Tooltip = _interopRequireDefault(require("@atlaskit/tooltip/Tooltip"));
31
30
  var _styles = require("../../styles");
32
31
  var _ToolbarArrowKeyNavigationProvider = require("../../ui-menu/ToolbarArrowKeyNavigationProvider");
@@ -364,16 +363,16 @@ function DropdownMenuItem(_ref) {
364
363
  css: function css() {
365
364
  return buttonStyles(item.isActive, submenuActive);
366
365
  },
367
- role: (0, _expValEquals.expValEquals)('platform_editor_august_a11y', 'isEnabled', true) ? shouldUseDefaultRole ? undefined : 'menuitem' : undefined,
366
+ role: shouldUseDefaultRole ? undefined : 'menuitem',
368
367
  tabIndex: tabIndex,
369
368
  "aria-disabled": item.isDisabled ? 'true' : 'false',
370
- "aria-expanded": (0, _expValEquals.expValEquals)('platform_editor_august_a11y', 'isEnabled', true) ? item['aria-expanded'] : undefined,
369
+ "aria-expanded": item['aria-expanded'],
371
370
  onMouseDown: _handleSubmenuActive
372
371
  }, (0, _react2.jsx)(_customItem.default, {
373
372
  item: item,
374
373
  key: (_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : String(item.content),
375
374
  testId: testId,
376
- role: shouldUseDefaultRole ? 'button' : (0, _expValEquals.expValEquals)('platform_editor_august_a11y', 'isEnabled', true) ? undefined : 'menuitem',
375
+ role: shouldUseDefaultRole ? 'button' : undefined,
377
376
  iconBefore: item.elemBefore,
378
377
  iconAfter: item.elemAfter,
379
378
  isDisabled: item.isDisabled,
@@ -384,8 +383,7 @@ function DropdownMenuItem(_ref) {
384
383
  onMouseDown: onMouseDown,
385
384
  component: DropdownMenuItemCustomComponent,
386
385
  onMouseEnter: onMouseEnterHandler,
387
- onMouseLeave: onMouseLeaveHandler,
388
- "aria-expanded": (0, _expValEquals.expValEquals)('platform_editor_august_a11y', 'isEnabled', true) ? undefined : item['aria-expanded']
386
+ onMouseLeave: onMouseLeaveHandler
389
387
  }, item.content));
390
388
  if (item.tooltipDescription) {
391
389
  var _item$key3;
@@ -76,18 +76,6 @@ Object.defineProperty(exports, "SelectedState", {
76
76
  return _SelectedState.SelectedState;
77
77
  }
78
78
  });
79
- Object.defineProperty(exports, "TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS", {
80
- enumerable: true,
81
- get: function get() {
82
- return _TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS;
83
- }
84
- });
85
- Object.defineProperty(exports, "TTI_SEVERITY_THRESHOLD_DEFAULTS", {
86
- enumerable: true,
87
- get: function get() {
88
- return _TTI_SEVERITY_THRESHOLD_DEFAULTS.TTI_SEVERITY_THRESHOLD_DEFAULTS;
89
- }
90
- });
91
79
  Object.defineProperty(exports, "UNSUPPORTED_CONTENT_LEVEL_SEVERITY", {
92
80
  enumerable: true,
93
81
  get: function get() {
@@ -540,12 +528,6 @@ Object.defineProperty(exports, "getPageElementCounts", {
540
528
  return _pageElementCounts.getPageElementCounts;
541
529
  }
542
530
  });
543
- Object.defineProperty(exports, "getPerformanceOptions", {
544
- enumerable: true,
545
- get: function get() {
546
- return _getPerformanceOptions.getPerformanceOptions;
547
- }
548
- });
549
531
  Object.defineProperty(exports, "getPropsDifference", {
550
532
  enumerable: true,
551
533
  get: function get() {
@@ -588,12 +570,6 @@ Object.defineProperty(exports, "getStepRange", {
588
570
  return _getStepRange.getStepRange;
589
571
  }
590
572
  });
591
- Object.defineProperty(exports, "getTTISeverity", {
592
- enumerable: true,
593
- get: function get() {
594
- return _measureTti.getTTISeverity;
595
- }
596
- });
597
573
  Object.defineProperty(exports, "getTimeSince", {
598
574
  enumerable: true,
599
575
  get: function get() {
@@ -918,12 +894,6 @@ Object.defineProperty(exports, "measureRender", {
918
894
  return _measureRender.measureRender;
919
895
  }
920
896
  });
921
- Object.defineProperty(exports, "measureTTI", {
922
- enumerable: true,
923
- get: function get() {
924
- return _measureTti.measureTTI;
925
- }
926
- });
927
897
  Object.defineProperty(exports, "nodeToJSON", {
928
898
  enumerable: true,
929
899
  get: function get() {
@@ -1052,12 +1022,6 @@ Object.defineProperty(exports, "startMeasure", {
1052
1022
  return _measure.startMeasure;
1053
1023
  }
1054
1024
  });
1055
- Object.defineProperty(exports, "startMeasureReactNodeViewRendered", {
1056
- enumerable: true,
1057
- get: function get() {
1058
- return _startMeasureReactNodeViewRendered.startMeasureReactNodeViewRendered;
1059
- }
1060
- });
1061
1025
  Object.defineProperty(exports, "stepAddsOneOf", {
1062
1026
  enumerable: true,
1063
1027
  get: function get() {
@@ -1076,12 +1040,6 @@ Object.defineProperty(exports, "stopMeasure", {
1076
1040
  return _measure.stopMeasure;
1077
1041
  }
1078
1042
  });
1079
- Object.defineProperty(exports, "stopMeasureReactNodeViewRendered", {
1080
- enumerable: true,
1081
- get: function get() {
1082
- return _getPerformanceOptions.stopMeasureReactNodeViewRendered;
1083
- }
1084
- });
1085
1043
  Object.defineProperty(exports, "timestampToIsoFormat", {
1086
1044
  enumerable: true,
1087
1045
  get: function get() {
@@ -1252,9 +1210,6 @@ var _getUnsupportedContentLevelData = require("./unsupportedContent/get-unsuppor
1252
1210
  var _trackUnsupportedContent = require("./track-unsupported-content");
1253
1211
  var _measureRender = require("./performance/measure-render");
1254
1212
  var _measure = require("./performance/measure");
1255
- var _TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS = require("./performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS");
1256
- var _TTI_SEVERITY_THRESHOLD_DEFAULTS = require("./performance/TTI_SEVERITY_THRESHOLD_DEFAULTS");
1257
- var _measureTti = require("./performance/measure-tti");
1258
1213
  var _isPerformanceApiAvailable = require("./performance/is-performance-api-available");
1259
1214
  var _isPerformanceObserverAvailable = require("./performance/isPerformanceObserverAvailable");
1260
1215
  var _getRequestToResponseTime = require("./performance/getRequestToResponseTime");
@@ -1270,8 +1225,6 @@ var _isTextInput = require("./is-text-input");
1270
1225
  var _whitespace = require("../whitespace");
1271
1226
  var _shouldForceTracking = require("./should-force-tracking");
1272
1227
  var _getModeFromTheme = require("./getModeFromTheme");
1273
- var _getPerformanceOptions = require("./get-performance-options");
1274
- var _startMeasureReactNodeViewRendered = require("./startMeasureReactNodeViewRendered");
1275
1228
  var _browserExtensions = require("./browser-extensions");
1276
1229
  var _renderCount = require("./profiler/render-count");
1277
1230
  var _validateUsingSpec = require("./validate-using-spec");
@@ -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
+ };
@@ -233,7 +233,7 @@ const 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
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -421,8 +421,7 @@ export function ElementItem({
421
421
  title: title
422
422
  }),
423
423
  isSelected: selected,
424
- "aria-describedby": expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? undefined : title,
425
- "aria-label": expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? title : undefined,
424
+ "aria-label": title,
426
425
  ref: ref,
427
426
  testId: `element-item-${index}`,
428
427
  id: `searched-item-${index}`,
@@ -337,7 +337,7 @@ function MobileBrowser({
337
337
  searchTerm: searchTerm,
338
338
  items: items,
339
339
  selectedItemIndex: selectedItemIndex,
340
- ariaControlsId: expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? ELEMENT_BROWSER_LIST_ID : undefined
340
+ ariaControlsId: ELEMENT_BROWSER_LIST_ID
341
341
  }), showCategories && jsx("nav", {
342
342
  css: mobileCategoryListWrapper,
343
343
  tabIndex: -1
@@ -351,7 +351,7 @@ function MobileBrowser({
351
351
  setFocusOnSearch: setFocusOnSearch
352
352
  }))), jsx("div", {
353
353
  css: mobileMainContent,
354
- id: expValEquals('platform_editor_august_a11y', 'isEnabled', true) ? ELEMENT_BROWSER_LIST_ID : undefined
354
+ id: ELEMENT_BROWSER_LIST_ID
355
355
  }, jsx(ElementList, {
356
356
  items: items,
357
357
  mode: mode,
@@ -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
+ };
@@ -14,7 +14,6 @@ import classnames from 'classnames';
14
14
  import { useIntl } from 'react-intl';
15
15
  import EditorFileIcon from '@atlaskit/icon/core/file';
16
16
  import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
17
- import { fg } from '@atlaskit/platform-feature-flags/fg';
18
17
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
19
18
  import { useSharedPluginStateWithSelector } from '../../hooks';
20
19
  import { placeholderTextMessages } from '../../messages/placeholder-text';
@@ -25,26 +24,7 @@ import { ExtensionFloatingLabel } from '../Extension/Lozenge/ExtensionFloatingLa
25
24
  import { shouldExtensionBreakout } from '../utils/should-extension-breakout';
26
25
  import { useMultiBodiedExtensionActions } from './action-api';
27
26
  import { mbeExtensionWrapperCSSStyles, mbeExtensionWrapperCSSStylesOld, overlayStyles, overlayStylesOld } from './styles';
28
- const getContainerCssExtendedStyles = (activeChildIndex, showMacroInteractionDesignUpdates) => {
29
- if (fg('platform_editor_nested_mbe_frames')) {
30
- return sharedMultiBodiedExtensionStyles.mbeExtensionContainer;
31
- }
32
- const activeFrameSelector = `.multiBodiedExtension-content-dom-wrapper > [data-extension-frame='true']:nth-of-type(${activeChildIndex + 1})`;
33
-
34
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
35
- return css(sharedMultiBodiedExtensionStyles.mbeExtensionContainer, {
36
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
37
- [activeFrameSelector]: css(
38
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
39
- sharedMultiBodiedExtensionStyles.extensionFrameContent,
40
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
41
- showMacroInteractionDesignUpdates && removeMarginsAndBorder)
42
- });
43
- };
44
27
  const getFramesActiveFrameStyles = (activeChildIndex, showMacroInteractionDesignUpdates) => {
45
- if (!fg('platform_editor_nested_mbe_frames')) {
46
- return undefined;
47
- }
48
28
  const activeFrameSelector = `& > .multiBodiedExtension-content-dom-wrapper > [data-extension-frame='true']:nth-of-type(${activeChildIndex + 1})`;
49
29
  return css({
50
30
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
@@ -350,10 +330,10 @@ const MultiBodiedExtensionWithWidth = ({
350
330
  "data-testid": "multiBodiedExtension--overlay"
351
331
  }), getWrapperTitleContent(imageData, title, showMacroInteractionDesignUpdates), jsx("div", {
352
332
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
353
- className: containerClassNames,
354
- css: [/* eslint-disable @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766 */
355
- getContainerCssExtendedStyles(activeChildIndex, showMacroInteractionDesignUpdates)
356
- /* eslint-enable @atlaskit/design-system/consistent-css-prop-usage */],
333
+ className: containerClassNames
334
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
335
+ ,
336
+ css: sharedMultiBodiedExtensionStyles.mbeExtensionContainer,
357
337
  "data-testid": "multiBodiedExtension--container",
358
338
  "data-multiBodiedExtension-container": true,
359
339
  "data-active-child-index": activeChildIndex
@@ -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.0";
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.0";
17
+ const packageVersion = "128.3.2";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({