@atlaskit/editor-common 128.3.2 → 129.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +53 -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/messages/insert-block.js +0 -5
  9. package/dist/cjs/monitoring/error.js +1 -1
  10. package/dist/cjs/quick-insert/snippetMenuRank.js +35 -0
  11. package/dist/cjs/quick-insert/utils.js +9 -14
  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/type-ahead/messages.js +0 -10
  15. package/dist/cjs/ui/DropList/index.js +1 -1
  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/extensibility/Extension/Extension/index.js +17 -3
  20. package/dist/es2019/extensibility/Extension/ExtensionCommentBadge.js +60 -0
  21. package/dist/es2019/media-single/MediaBadges.js +12 -79
  22. package/dist/es2019/messages/insert-block.js +0 -5
  23. package/dist/es2019/monitoring/error.js +1 -1
  24. package/dist/es2019/quick-insert/snippetMenuRank.js +30 -0
  25. package/dist/es2019/quick-insert/utils.js +7 -12
  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/type-ahead/messages.js +0 -10
  29. package/dist/es2019/ui/DropList/index.js +1 -1
  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/extensibility/Extension/Extension/index.js +21 -3
  34. package/dist/esm/extensibility/Extension/ExtensionCommentBadge.js +101 -0
  35. package/dist/esm/media-single/MediaBadges.js +12 -82
  36. package/dist/esm/messages/insert-block.js +0 -5
  37. package/dist/esm/monitoring/error.js +1 -1
  38. package/dist/esm/quick-insert/snippetMenuRank.js +29 -0
  39. package/dist/esm/quick-insert/utils.js +9 -14
  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/type-ahead/messages.js +0 -10
  43. package/dist/esm/ui/DropList/index.js +1 -1
  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/messages/insert-block.d.ts +0 -5
  54. package/dist/types/quick-insert/snippetMenuRank.d.ts +16 -0
  55. package/dist/types/type-ahead/messages.d.ts +0 -10
  56. package/dist/types/types/index.d.ts +1 -1
  57. package/dist/types/types/performance-tracking.d.ts +0 -22
  58. package/dist/types/types/type-ahead.d.ts +0 -7
  59. package/dist/types/utils/index.d.ts +0 -5
  60. package/package.json +7 -3
  61. package/quick-insert/snippet-menu-rank/package.json +10 -0
  62. package/analytics/types/performance-report/package.json +0 -10
  63. package/dist/cjs/analytics/types/performance-report.js +0 -1
  64. package/dist/cjs/quick-insert/boost-native-results-above-skills.js +0 -61
  65. package/dist/cjs/utils/get-performance-options.js +0 -65
  66. package/dist/cjs/utils/performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.js +0 -10
  67. package/dist/cjs/utils/performance/TTI_SEVERITY_THRESHOLD_DEFAULTS.js +0 -10
  68. package/dist/cjs/utils/performance/measure-tti.js +0 -112
  69. package/dist/cjs/utils/startMeasureReactNodeViewRendered.js +0 -11
  70. package/dist/es2019/analytics/types/performance-report.js +0 -0
  71. package/dist/es2019/quick-insert/boost-native-results-above-skills.js +0 -49
  72. package/dist/es2019/utils/get-performance-options.js +0 -54
  73. package/dist/es2019/utils/performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.js +0 -4
  74. package/dist/es2019/utils/performance/TTI_SEVERITY_THRESHOLD_DEFAULTS.js +0 -4
  75. package/dist/es2019/utils/performance/measure-tti.js +0 -91
  76. package/dist/es2019/utils/startMeasureReactNodeViewRendered.js +0 -6
  77. package/dist/esm/analytics/types/performance-report.js +0 -0
  78. package/dist/esm/quick-insert/boost-native-results-above-skills.js +0 -54
  79. package/dist/esm/utils/get-performance-options.js +0 -53
  80. package/dist/esm/utils/performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.js +0 -4
  81. package/dist/esm/utils/performance/TTI_SEVERITY_THRESHOLD_DEFAULTS.js +0 -4
  82. package/dist/esm/utils/performance/measure-tti.js +0 -94
  83. package/dist/esm/utils/startMeasureReactNodeViewRendered.js +0 -5
  84. package/dist/types/analytics/types/performance-report.d.ts +0 -24
  85. package/dist/types/quick-insert/boost-native-results-above-skills.d.ts +0 -21
  86. package/dist/types/utils/get-performance-options.d.ts +0 -14
  87. package/dist/types/utils/performance/TTI_FROM_INVOCATION_SEVERITY_THRESHOLD_DEFAULTS.d.ts +0 -4
  88. package/dist/types/utils/performance/TTI_SEVERITY_THRESHOLD_DEFAULTS.d.ts +0 -4
  89. package/dist/types/utils/performance/measure-tti.d.ts +0 -8
  90. package/dist/types/utils/startMeasureReactNodeViewRendered.d.ts +0 -3
  91. package/performance/measure-tti/package.json +0 -10
  92. package/utils/get-performance-options/package.json +0 -10
@@ -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
 
@@ -104,15 +104,5 @@ export const typeAheadListMessages = defineMessages({
104
104
  id: 'fabric.editor.emptySearchResultsSuggestion',
105
105
  defaultMessage: 'Select {buttonName} to browse inserts.',
106
106
  description: 'a prompt to suggest user to click a button to browse inserts when there are no search results'
107
- },
108
- emptySearchResultsSuggestionNew: {
109
- id: 'fabric.editor.emptySearchResultsSuggestionNew',
110
- defaultMessage: 'Select {askRovoName} for help, or {buttonName} to browse inserts.',
111
- description: 'a prompt to suggest user to click a button to browse inserts or ask Rovo for help when there are no search results'
112
- },
113
- emptySearchResultsSuggestionAskRovoOnly: {
114
- id: 'fabric.editor.emptySearchResultsSuggestionAskRovoOnly',
115
- defaultMessage: 'Select {askRovoName} for help.',
116
- description: 'a prompt to suggest user to ask Rovo for help when there are no search results and no browse inserts button is available'
117
107
  }
118
108
  });
@@ -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.4.0";
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;
@@ -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
+ };
@@ -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
  };
@@ -205,11 +205,6 @@ export var toolbarInsertBlockMessages = defineMessages({
205
205
  defaultMessage: 'Add a custom status label',
206
206
  description: 'Menu description shown in the quick insert menu. Explains that users can add custom status labels.'
207
207
  },
208
- askRovo: {
209
- id: 'fabric.editor.askRovo',
210
- defaultMessage: 'Ask Rovo',
211
- description: 'Button label shown in the quick insert empty results state. Allows users to ask Rovo AI for help.'
212
- },
213
208
  viewMore: {
214
209
  id: 'fabric.editor.viewMore',
215
210
  defaultMessage: 'View more',
@@ -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.1";
22
+ var packageVersion = "128.4.0";
23
23
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
24
24
  // Remove URL as it has UGC
25
25
  // Ignored via go/ees007
@@ -0,0 +1,29 @@
1
+ var MAX_DATE_MS = 8.64e15; // largest valid Date value
2
+ var FAVORITE_TIER = -2;
3
+ var CURATED_TIER = 1;
4
+ export var TEMPLATE_GALLERY_MENU_RANK = 0;
5
+
6
+ /**
7
+ * Menu rank for a Block template within the Block templates section. Lower ranks appear first.
8
+ * Each rank is its tier plus a fraction in [0, 1), so tiers never overlap.
9
+ *
10
+ * Negative ranks are intentional and valid. This is a `parents[].rank` sort key, not a Fuse score:
11
+ * the registry menu compares ranks by subtraction, and Fuse's 0–1 `score` is a separate value that
12
+ * is compared first when searching, so rank only orders templates with equal scores.
13
+ */
14
+ export var getSnippetMenuRank = function getSnippetMenuRank(_ref) {
15
+ var insertCount = _ref.insertCount,
16
+ isFavorite = _ref.isFavorite,
17
+ scope = _ref.scope,
18
+ updatedAt = _ref.updatedAt;
19
+ if (isFavorite) {
20
+ // Stays in (-2, -1.5]; more inserts rank first.
21
+ return FAVORITE_TIER + 1 / ((insertCount !== null && insertCount !== void 0 ? insertCount : 0) + 2);
22
+ }
23
+ if (scope !== 'GLOBAL') {
24
+ var time = Number.isFinite(updatedAt) ? Math.max(updatedAt, 1) : 1;
25
+ // USER and SITE templates stay in [-1, 0); newer updates rank first.
26
+ return -time / MAX_DATE_MS;
27
+ }
28
+ return CURATED_TIER;
29
+ };
@@ -4,8 +4,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
4
4
  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; }
5
5
  import Fuse from 'fuse.js';
6
6
  import memoizeOne from 'memoize-one';
7
- import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
8
- import { boostNativeResultsAboveSkills } from './boost-native-results-above-skills';
9
7
  var processQuickInsertItems = function processQuickInsertItems(items, intl) {
10
8
  return items.reduce(function (acc, item) {
11
9
  if (typeof item === 'function' &&
@@ -59,7 +57,7 @@ var options = {
59
57
  */
60
58
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
61
59
  export function find(query, items, prioritySortingFn) {
62
- var _rerankedResults$data, _rerankedResults$lega;
60
+ var _results$datasourceIn, _results$legacyIndex$;
63
61
  if (query === '') {
64
62
  // Copy and sort list by priority
65
63
  return items.slice(0).sort(function (a, b) {
@@ -78,28 +76,25 @@ export function find(query, items, prioritySortingFn) {
78
76
  var fuse = new Fuse(items, fuseOptions);
79
77
  var results = fuse.search(query);
80
78
 
81
- // platform_editor_insert_menu_ai: boost native editor elements above skills
82
- var rerankedResults = isExperimentEnabled('platform_editor_insert_menu_ai') ? boostNativeResultsAboveSkills(results) : results;
83
-
84
79
  // searching for jira work items macro first
85
- var datasourceIndex = rerankedResults.findIndex(function (r) {
80
+ var datasourceIndex = results.findIndex(function (r) {
86
81
  var _r$item$keywords;
87
82
  return r.item.id === 'datasource' && ((_r$item$keywords = r.item.keywords) === null || _r$item$keywords === void 0 ? void 0 : _r$item$keywords.includes('jira'));
88
83
  });
89
84
 
90
85
  // then searching for the legacy jira macro
91
- var legacyIndex = rerankedResults.findIndex(function (r) {
86
+ var legacyIndex = results.findIndex(function (r) {
92
87
  return typeof r.item.key === 'string' && r.item.key.endsWith(':jira');
93
88
  });
94
89
 
95
90
  // the jira legcy macro is found before the jira work items macro then swap the two
96
- if (datasourceIndex > 0 && legacyIndex >= 0 && legacyIndex < datasourceIndex && Math.abs(((_rerankedResults$data = rerankedResults[datasourceIndex].score) !== null && _rerankedResults$data !== void 0 ? _rerankedResults$data : 0) - ((_rerankedResults$lega = rerankedResults[legacyIndex].score) !== null && _rerankedResults$lega !== void 0 ? _rerankedResults$lega : 0)) < 0.2) {
97
- var _rerankedResults$spli = rerankedResults.splice(datasourceIndex, 1),
98
- _rerankedResults$spli2 = _slicedToArray(_rerankedResults$spli, 1),
99
- datasource = _rerankedResults$spli2[0];
100
- rerankedResults.splice(legacyIndex, 0, datasource);
91
+ if (datasourceIndex > 0 && legacyIndex >= 0 && legacyIndex < datasourceIndex && Math.abs(((_results$datasourceIn = results[datasourceIndex].score) !== null && _results$datasourceIn !== void 0 ? _results$datasourceIn : 0) - ((_results$legacyIndex$ = results[legacyIndex].score) !== null && _results$legacyIndex$ !== void 0 ? _results$legacyIndex$ : 0)) < 0.2) {
92
+ var _results$splice = results.splice(datasourceIndex, 1),
93
+ _results$splice2 = _slicedToArray(_results$splice, 1),
94
+ datasource = _results$splice2[0];
95
+ results.splice(legacyIndex, 0, datasource);
101
96
  }
102
- return rerankedResults.map(function (result) {
97
+ return results.map(function (result) {
103
98
  return result.item;
104
99
  });
105
100
  }
@@ -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