@atlaskit/editor-common 83.0.4 → 83.2.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 (57) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/extensibility/Extension/Extension/index.js +3 -1
  3. package/dist/cjs/extensibility/Extension/InlineExtension/index.js +3 -1
  4. package/dist/cjs/extensibility/Extension/Lozenge/ExtensionLabel.js +84 -42
  5. package/dist/cjs/extensibility/Extension/Lozenge/LozengeComponent.js +3 -1
  6. package/dist/cjs/extensibility/Extension/Lozenge/index.js +2 -0
  7. package/dist/cjs/extensibility/MultiBodiedExtension/index.js +3 -1
  8. package/dist/cjs/monitoring/error.js +1 -1
  9. package/dist/cjs/ui/DropList/index.js +1 -1
  10. package/dist/cjs/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.js +5 -2
  11. package/dist/cjs/ui-menu/ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider/index.js +11 -4
  12. package/dist/cjs/ui-menu/ArrowKeyNavigationProvider/index.js +8 -4
  13. package/dist/cjs/ui-menu/DropdownMenu/index.js +9 -2
  14. package/dist/cjs/ui-react/with-react-editor-view-outer-listeners.js +5 -2
  15. package/dist/es2019/extensibility/Extension/Extension/index.js +3 -1
  16. package/dist/es2019/extensibility/Extension/InlineExtension/index.js +3 -1
  17. package/dist/es2019/extensibility/Extension/Lozenge/ExtensionLabel.js +84 -44
  18. package/dist/es2019/extensibility/Extension/Lozenge/LozengeComponent.js +3 -1
  19. package/dist/es2019/extensibility/Extension/Lozenge/index.js +2 -0
  20. package/dist/es2019/extensibility/MultiBodiedExtension/index.js +3 -1
  21. package/dist/es2019/monitoring/error.js +1 -1
  22. package/dist/es2019/ui/DropList/index.js +1 -1
  23. package/dist/es2019/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.js +5 -2
  24. package/dist/es2019/ui-menu/ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider/index.js +11 -4
  25. package/dist/es2019/ui-menu/ArrowKeyNavigationProvider/index.js +6 -2
  26. package/dist/es2019/ui-menu/DropdownMenu/index.js +10 -2
  27. package/dist/es2019/ui-react/with-react-editor-view-outer-listeners.js +5 -2
  28. package/dist/esm/extensibility/Extension/Extension/index.js +3 -1
  29. package/dist/esm/extensibility/Extension/InlineExtension/index.js +3 -1
  30. package/dist/esm/extensibility/Extension/Lozenge/ExtensionLabel.js +86 -44
  31. package/dist/esm/extensibility/Extension/Lozenge/LozengeComponent.js +3 -1
  32. package/dist/esm/extensibility/Extension/Lozenge/index.js +2 -0
  33. package/dist/esm/extensibility/MultiBodiedExtension/index.js +3 -1
  34. package/dist/esm/monitoring/error.js +1 -1
  35. package/dist/esm/ui/DropList/index.js +1 -1
  36. package/dist/esm/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.js +5 -2
  37. package/dist/esm/ui-menu/ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider/index.js +11 -4
  38. package/dist/esm/ui-menu/ArrowKeyNavigationProvider/index.js +8 -4
  39. package/dist/esm/ui-menu/DropdownMenu/index.js +9 -2
  40. package/dist/esm/ui-react/with-react-editor-view-outer-listeners.js +5 -2
  41. package/dist/types/collab/index.d.ts +26 -0
  42. package/dist/types/extensibility/Extension/Lozenge/ExtensionLabel.d.ts +2 -1
  43. package/dist/types/extensibility/Extension/Lozenge/LozengeComponent.d.ts +2 -1
  44. package/dist/types/extensibility/Extension/Lozenge/index.d.ts +1 -0
  45. package/dist/types/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.d.ts +1 -1
  46. package/dist/types/ui-menu/ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider/index.d.ts +1 -1
  47. package/dist/types/ui-menu/ArrowKeyNavigationProvider/types.d.ts +2 -0
  48. package/dist/types/ui-react/ReactEditorViewContext.d.ts +1 -0
  49. package/dist/types-ts4.5/collab/index.d.ts +26 -0
  50. package/dist/types-ts4.5/extensibility/Extension/Lozenge/ExtensionLabel.d.ts +2 -1
  51. package/dist/types-ts4.5/extensibility/Extension/Lozenge/LozengeComponent.d.ts +2 -1
  52. package/dist/types-ts4.5/extensibility/Extension/Lozenge/index.d.ts +1 -0
  53. package/dist/types-ts4.5/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.d.ts +1 -1
  54. package/dist/types-ts4.5/ui-menu/ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider/index.d.ts +1 -1
  55. package/dist/types-ts4.5/ui-menu/ArrowKeyNavigationProvider/types.d.ts +2 -0
  56. package/dist/types-ts4.5/ui-react/ReactEditorViewContext.d.ts +1 -0
  57. package/package.json +4 -1
@@ -1,33 +1,36 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  /** @jsx jsx */
2
- import { useCallback } from 'react';
3
+ import { Fragment } from 'react';
3
4
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
4
5
  import { css, jsx } from '@emotion/react';
5
6
  import classnames from 'classnames';
6
- import { N0, N30, N40, N500 } from '@atlaskit/theme/colors';
7
- const labelStyles = css({
7
+ import { defineMessages, useIntl } from 'react-intl-next';
8
+ import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
9
+ import { N0, N30, N40, N500, N800 } from '@atlaskit/theme/colors';
10
+ import Tooltip from '@atlaskit/tooltip';
11
+ const containerStyles = css({
12
+ textAlign: 'left',
13
+ zIndex: 1,
14
+ position: 'relative',
15
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
16
+ '&.bodied': {
17
+ marginTop: "var(--ds-space-300, 24px)"
18
+ }
19
+ });
20
+ const sharedLabelStyles = css({
8
21
  opacity: 0,
22
+ lineHeight: 1,
9
23
  display: 'inline-flex',
10
- width: 'max-content',
11
24
  justifyContent: 'left',
12
25
  position: 'absolute',
13
- // Unfortunately, these need to be these exact numbers - otherwise there will be a noticeable gap/overlap
26
+ width: 'max-content',
14
27
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
15
28
  top: '-19px',
16
29
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
17
- '&.inline': {
18
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
19
- top: '-18px',
20
- marginLeft: "var(--ds-space-150, 12px)"
21
- },
22
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
23
30
  '&.show-label': {
24
31
  cursor: 'pointer',
25
- background: `var(--ds-background-accent-gray-subtle-pressed, ${N40})`,
26
- color: `var(--ds-text-subtle, ${N500})`,
27
32
  opacity: 1
28
33
  },
29
- borderRadius: `${"var(--ds-border-radius, 3px)"} ${"var(--ds-border-radius, 3px)"} 0 0`,
30
- lineHeight: 1,
31
34
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
32
35
  '&.nested': {
33
36
  // Need to add indent if the node is nested since we removed previous indentation styles to make it fit properly
@@ -35,26 +38,49 @@ const labelStyles = css({
35
38
  marginLeft: "var(--ds-space-150, 12px)"
36
39
  },
37
40
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
38
- '&.bodied-background': {
39
- background: `var(--ds-surface, ${N0})`
40
- },
41
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
42
- '&.bodied-border': {
43
- boxShadow: `0 0 0 1px ${`var(--ds-border, ${N30})`}`
41
+ '&.inline': {
42
+ marginLeft: "var(--ds-space-150, 12px)",
43
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
44
+ top: '-18px'
44
45
  }
45
46
  });
47
+ const buttonLabelStyles = css({
48
+ alignItems: 'center',
49
+ borderRadius: "var(--ds-border-radius, 3px)",
50
+ paddingLeft: "var(--ds-space-050, 4px)",
51
+ paddingRight: "var(--ds-space-050, 4px)",
52
+ color: `var(--ds-text-subtle, ${N800})`,
53
+ backgroundColor: `var(--ds-background-accent-gray-subtlest, ${N30})`
54
+ });
55
+ const placeholderStyles = css({
56
+ height: "var(--ds-space-150, 12px)"
57
+ });
46
58
  const textStyles = css({
47
59
  fontSize: '14px',
48
60
  fontWeight: 'normal',
49
61
  padding: `${"var(--ds-space-025, 2px)"} ${"var(--ds-space-050, 4px)"}`
50
62
  });
51
- const containerStyles = css({
52
- textAlign: 'left',
53
- zIndex: 1,
54
- position: 'relative',
63
+ const originalLabelStyles = css({
64
+ borderRadius: `${"var(--ds-border-radius, 3px)"} ${"var(--ds-border-radius, 3px)"} 0 0`,
55
65
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
56
- '&.bodied': {
57
- marginTop: "var(--ds-space-300, 24px)"
66
+ '&.show-label': {
67
+ background: `var(--ds-background-accent-gray-subtle-pressed, ${N40})`,
68
+ color: `var(--ds-text-subtle, ${N500})`
69
+ },
70
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
71
+ '&.bodied-background': {
72
+ background: `var(--ds-surface, ${N0})`
73
+ },
74
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
75
+ '&.bodied-border': {
76
+ boxShadow: `0 0 0 1px ${`var(--ds-border, ${N30})`}`
77
+ }
78
+ });
79
+ const i18n = defineMessages({
80
+ configure: {
81
+ id: 'editor-common-extensibility.macro.button.configure',
82
+ defaultMessage: 'Configure',
83
+ description: 'Text in tooltip that tells user they can configure the specific macro.'
58
84
  }
59
85
  });
60
86
  export const ExtensionLabel = ({
@@ -64,8 +90,11 @@ export const ExtensionLabel = ({
64
90
  customContainerStyles,
65
91
  isNodeNested,
66
92
  setIsNodeHovered,
67
- isBodiedMacro
93
+ isBodiedMacro,
94
+ showMacroButtonUpdates
68
95
  }) => {
96
+ const intl = useIntl();
97
+ const tooltipText = `${intl.formatMessage(i18n.configure)} ${text}`;
69
98
  const containerClassNames = classnames({
70
99
  bodied: isBodiedMacro
71
100
  });
@@ -73,20 +102,10 @@ export const ExtensionLabel = ({
73
102
  nested: isNodeNested,
74
103
  inline: extensionName === 'inlineExtension',
75
104
  bodied: isBodiedMacro,
76
- 'bodied-border': isBodiedMacro && !isNodeHovered,
77
- 'bodied-background': isBodiedMacro && !isNodeHovered,
105
+ 'bodied-border': isBodiedMacro && !isNodeHovered && !showMacroButtonUpdates,
106
+ 'bodied-background': isBodiedMacro && !isNodeHovered && !showMacroButtonUpdates,
78
107
  'show-label': isNodeHovered || isBodiedMacro
79
108
  });
80
- const handleMouseEnter = useCallback(() => {
81
- // If current node is hovered and the label is hovered,
82
- // consider the node as hovered so we can display the label for users to click on
83
- if (isNodeHovered) {
84
- setIsNodeHovered === null || setIsNodeHovered === void 0 ? void 0 : setIsNodeHovered(true);
85
- }
86
- }, [isNodeHovered, setIsNodeHovered]);
87
- const handleMouseLeave = useCallback(() => {
88
- setIsNodeHovered === null || setIsNodeHovered === void 0 ? void 0 : setIsNodeHovered(false);
89
- }, [setIsNodeHovered]);
90
109
  return jsx("div", {
91
110
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
92
111
  css: containerStyles
@@ -96,12 +115,33 @@ export const ExtensionLabel = ({
96
115
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
97
116
  ,
98
117
  style: customContainerStyles,
99
- onMouseEnter: handleMouseEnter,
100
- onMouseLeave: handleMouseLeave,
118
+ onMouseOver: () => {
119
+ setIsNodeHovered === null || setIsNodeHovered === void 0 ? void 0 : setIsNodeHovered(true);
120
+ },
121
+ onMouseLeave: () => {
122
+ setIsNodeHovered === null || setIsNodeHovered === void 0 ? void 0 : setIsNodeHovered(false);
123
+ },
101
124
  "data-testid": "new-lozenge-container"
102
- }, jsx("span", {
125
+ }, showMacroButtonUpdates ? jsx(Fragment, null, jsx(Tooltip, {
126
+ content: tooltipText,
127
+ position: "top"
128
+ }, tooltipProps => jsx("span", _extends({
129
+ "data-testid": "new-lozenge-button"
130
+ }, tooltipProps, {
131
+ css: [sharedLabelStyles, buttonLabelStyles]
132
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
133
+ ,
134
+ className: labelClassNames
135
+ }), text, " ", jsx(PreferencesIcon, {
136
+ label: ""
137
+ }))), jsx("div", {
138
+ "data-testid": "placeholder",
139
+ css: placeholderStyles
140
+ })) : jsx("span", {
103
141
  "data-testid": "new-lozenge",
104
- css: labelStyles,
142
+ css: [sharedLabelStyles, originalLabelStyles]
143
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
144
+ ,
105
145
  className: labelClassNames
106
146
  }, jsx("span", {
107
147
  css: textStyles
@@ -16,6 +16,7 @@ export const LozengeComponent = ({
16
16
  params,
17
17
  renderImage,
18
18
  showMacroInteractionDesignUpdates,
19
+ showMacroButtonUpdates,
19
20
  customContainerStyles,
20
21
  isNodeHovered,
21
22
  isNodeNested,
@@ -31,7 +32,8 @@ export const LozengeComponent = ({
31
32
  isNodeNested: isNodeNested,
32
33
  customContainerStyles: customContainerStyles,
33
34
  setIsNodeHovered: setIsNodeHovered,
34
- isBodiedMacro: isBodiedMacro
35
+ isBodiedMacro: isBodiedMacro,
36
+ showMacroButtonUpdates: showMacroButtonUpdates
35
37
  });
36
38
  }
37
39
  const isBlockExtension = extensionName === 'extension';
@@ -29,6 +29,7 @@ export default class ExtensionLozenge extends Component {
29
29
  _defineProperty(this, "renderFallback", lozengeData => {
30
30
  const {
31
31
  showMacroInteractionDesignUpdates,
32
+ showMacroButtonUpdates,
32
33
  isNodeSelected,
33
34
  isNodeHovered,
34
35
  isNodeNested,
@@ -50,6 +51,7 @@ export default class ExtensionLozenge extends Component {
50
51
  isNodeSelected: isNodeSelected,
51
52
  isNodeNested: isNodeNested,
52
53
  showMacroInteractionDesignUpdates: showMacroInteractionDesignUpdates,
54
+ showMacroButtonUpdates: showMacroButtonUpdates,
53
55
  extensionName: name,
54
56
  lozengeData: lozengeData,
55
57
  params: params,
@@ -76,7 +76,8 @@ const MultiBodiedExtensionWithWidth = ({
76
76
  setIsNodeHovered
77
77
  }) => {
78
78
  const {
79
- showMacroInteractionDesignUpdates
79
+ showMacroInteractionDesignUpdates,
80
+ showMacroButtonUpdates
80
81
  } = macroInteractionDesignFeatureFlags || {};
81
82
  const {
82
83
  parameters,
@@ -152,6 +153,7 @@ const MultiBodiedExtensionWithWidth = ({
152
153
  isNodeSelected: isNodeSelected,
153
154
  node: node,
154
155
  showMacroInteractionDesignUpdates: true,
156
+ showMacroButtonUpdates: showMacroButtonUpdates,
155
157
  customContainerStyles: mbeWrapperStyles,
156
158
  isNodeHovered: isNodeHovered,
157
159
  isNodeNested: isNodeNested,
@@ -1,7 +1,7 @@
1
1
  import { isFedRamp } from './environment';
2
2
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
3
3
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
4
- const packageVersion = "83.0.4";
4
+ const packageVersion = "83.2.0";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // TODO: Sanitise the URL instead of just removing it
@@ -9,7 +9,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
9
9
  import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
10
10
  import Layer from '../Layer';
11
11
  const packageName = "@atlaskit/editor-common";
12
- const packageVersion = "83.0.4";
12
+ const packageVersion = "83.2.0";
13
13
  const halfFocusRing = 1;
14
14
  const dropOffset = '0, 8';
15
15
  class DropList extends Component {
@@ -1,4 +1,5 @@
1
1
  import React, { useLayoutEffect, useRef, useState } from 'react';
2
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
3
  /**
3
4
  * This component is a wrapper for color picker which listens to keydown events of children
4
5
  * and handles arrow key navigation
@@ -12,12 +13,14 @@ export const ColorPaletteArrowKeyNavigationProvider = ({
12
13
  handleClose,
13
14
  closeOnTab,
14
15
  editorRef,
15
- ignoreEscapeKey
16
+ ignoreEscapeKey,
17
+ popupsMountPoint
16
18
  }) => {
17
19
  const wrapperRef = useRef(null);
18
20
  const currentSelectedColumnIndex = useRef(selectedColumnIndex === -1 ? 0 : selectedColumnIndex);
19
21
  const currentSelectedRowIndex = useRef(selectedRowIndex === -1 ? 0 : selectedRowIndex);
20
- const [listenerTargetElement] = useState(editorRef.current);
22
+ const element = getBooleanFF('platform.editor.a11y-main-toolbar-navigation_osrty') && popupsMountPoint ? popupsMountPoint : editorRef.current;
23
+ const [listenerTargetElement] = useState(element);
21
24
  const incrementRowIndex = (rowElements, columnElements) => {
22
25
  if (currentSelectedRowIndex.current === rowElements.length - 1) {
23
26
  currentSelectedRowIndex.current = 0;
@@ -1,4 +1,5 @@
1
1
  import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
2
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
2
3
  const hasEnabledItems = list => list.some(item => item.getAttribute('aria-disabled') !== 'true');
3
4
 
4
5
  /**
@@ -12,11 +13,13 @@ export const MenuArrowKeyNavigationProvider = ({
12
13
  keyDownHandlerContext,
13
14
  closeOnTab,
14
15
  onSelection,
15
- editorRef
16
+ editorRef,
17
+ popupsMountPoint
16
18
  }) => {
17
19
  const wrapperRef = useRef(null);
18
20
  const [currentSelectedItemIndex, setCurrentSelectedItemIndex] = useState(-1);
19
- const [listenerTargetElement] = useState(editorRef.current);
21
+ const element = getBooleanFF('platform.editor.a11y-main-toolbar-navigation_osrty') && popupsMountPoint ? [popupsMountPoint, editorRef.current] : [editorRef.current];
22
+ const [listenerTargetElement] = useState(element);
20
23
  const incrementIndex = useCallback(list => {
21
24
  const currentIndex = currentSelectedItemIndex;
22
25
  let nextIndex = (currentIndex + 1) % list.length;
@@ -134,9 +137,13 @@ export const MenuArrowKeyNavigationProvider = ({
134
137
  return;
135
138
  }
136
139
  };
137
- listenerTargetElement && listenerTargetElement.addEventListener('keydown', handleKeyDown);
140
+ listenerTargetElement && listenerTargetElement.forEach(function (elem) {
141
+ elem && elem.addEventListener('keydown', handleKeyDown);
142
+ });
138
143
  return () => {
139
- listenerTargetElement && listenerTargetElement.removeEventListener('keydown', handleKeyDown);
144
+ listenerTargetElement && listenerTargetElement.forEach(function (elem) {
145
+ elem && elem.removeEventListener('keydown', handleKeyDown);
146
+ });
140
147
  };
141
148
  }, [currentSelectedItemIndex, wrapperRef, handleClose, disableArrowKeyNavigation, keyDownHandlerContext, closeOnTab, onSelection, incrementIndex, decrementIndex, listenerTargetElement]);
142
149
  return /*#__PURE__*/React.createElement("div", {
@@ -12,6 +12,7 @@ export const ArrowKeyNavigationProvider = props => {
12
12
  } = props;
13
13
  if (type === ArrowKeyNavigationType.COLOR) {
14
14
  return /*#__PURE__*/React.createElement(ReactEditorViewContext.Consumer, null, ({
15
+ popupsMountPoint,
15
16
  editorView,
16
17
  editorRef
17
18
  }) => editorRef && /*#__PURE__*/React.createElement(ColorPaletteArrowKeyNavigationProvider, _extends({
@@ -19,13 +20,16 @@ export const ArrowKeyNavigationProvider = props => {
19
20
  selectedColumnIndex: props.selectedColumnIndex,
20
21
  isOpenedByKeyboard: props.isOpenedByKeyboard,
21
22
  isPopupPositioned: props.isPopupPositioned,
22
- editorRef: editorRef
23
+ editorRef: editorRef,
24
+ popupsMountPoint: popupsMountPoint
23
25
  }, restProps), children));
24
26
  }
25
27
  return /*#__PURE__*/React.createElement(ReactEditorViewContext.Consumer, null, ({
28
+ popupsMountPoint,
26
29
  editorView,
27
30
  editorRef
28
31
  }) => editorRef && /*#__PURE__*/React.createElement(MenuArrowKeyNavigationProvider, _extends({
29
- editorRef: editorRef
32
+ editorRef: editorRef,
33
+ popupsMountPoint: popupsMountPoint
30
34
  }, restProps), children));
31
35
  };
@@ -241,14 +241,22 @@ export default class DropdownMenuWrapper extends PureComponent {
241
241
  }, children), isOpen ? this.renderDropdownMenu() : null);
242
242
  }
243
243
  componentDidUpdate(previousProps) {
244
- const isOpenToggled = this.props.isOpen !== previousProps.isOpen;
245
- if (this.props.isOpen && isOpenToggled) {
244
+ const {
245
+ mountTo,
246
+ isOpen
247
+ } = this.props;
248
+ const isOpenToggled = isOpen !== previousProps.isOpen;
249
+ if (isOpen && isOpenToggled) {
246
250
  if (typeof this.props.shouldFocusFirstItem === 'function' && this.props.shouldFocusFirstItem()) {
247
251
  var _this$state$target2;
248
252
  const keyboardEvent = new KeyboardEvent('keydown', {
249
253
  key: 'ArrowDown',
250
254
  bubbles: true
251
255
  });
256
+ if (mountTo && getBooleanFF('platform.editor.a11y-main-toolbar-navigation_osrty')) {
257
+ mountTo.dispatchEvent(keyboardEvent);
258
+ return;
259
+ }
252
260
  (_this$state$target2 = this.state.target) === null || _this$state$target2 === void 0 ? void 0 : _this$state$target2.dispatchEvent(keyboardEvent);
253
261
  }
254
262
  }
@@ -1,6 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React, { PureComponent, useEffect, useState } from 'react';
3
3
  import ReactDOM from 'react-dom';
4
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
5
  import ReactEditorViewContext from './ReactEditorViewContext';
5
6
 
6
7
  // This needs exporting to be used alongisde `withReactEditorViewOuterListeners`
@@ -50,7 +51,7 @@ class WithOutsideClick extends PureComponent {
50
51
  if (this.props.handleEscapeKeydown) {
51
52
  var _this$props$editorRef;
52
53
  // Attached event to the menu so that 'ESC' events from the opened menu also will be handled.
53
- (((_this$props$editorRef = this.props.editorRef) === null || _this$props$editorRef === void 0 ? void 0 : _this$props$editorRef.current) || this.props.targetRef || document).addEventListener('keydown', this.handleKeydown, false);
54
+ (getBooleanFF('platform.editor.a11y-main-toolbar-navigation_osrty') && this.props.popupsMountPoint ? this.props.popupsMountPoint : undefined || ((_this$props$editorRef = this.props.editorRef) === null || _this$props$editorRef === void 0 ? void 0 : _this$props$editorRef.current) || this.props.targetRef || document).addEventListener('keydown', this.handleKeydown, false);
54
55
  }
55
56
  }
56
57
  componentWillUnmount() {
@@ -59,7 +60,7 @@ class WithOutsideClick extends PureComponent {
59
60
  }
60
61
  if (this.props.handleEscapeKeydown) {
61
62
  var _this$props$editorRef2;
62
- (((_this$props$editorRef2 = this.props.editorRef) === null || _this$props$editorRef2 === void 0 ? void 0 : _this$props$editorRef2.current) || this.props.targetRef || document).removeEventListener('keydown', this.handleKeydown, false);
63
+ (getBooleanFF('platform.editor.a11y-main-toolbar-navigation_osrty') && this.props.popupsMountPoint ? this.props.popupsMountPoint : undefined || ((_this$props$editorRef2 = this.props.editorRef) === null || _this$props$editorRef2 === void 0 ? void 0 : _this$props$editorRef2.current) || this.props.targetRef || document).removeEventListener('keydown', this.handleKeydown, false);
63
64
  }
64
65
  }
65
66
  render() {
@@ -86,11 +87,13 @@ export default function withReactEditorViewOuterListeners(Component) {
86
87
  }, [isActiveProp]);
87
88
  return /*#__PURE__*/React.createElement(ReactEditorViewContext.Consumer, null, ({
88
89
  editorView,
90
+ popupsMountPoint,
89
91
  editorRef
90
92
  }) => /*#__PURE__*/React.createElement(WithOutsideClick, {
91
93
  editorView: editorView,
92
94
  editorRef: editorRef,
93
95
  targetRef: props.targetRef,
96
+ popupsMountPoint: popupsMountPoint,
94
97
  isActiveComponent: isActiveComponent,
95
98
  handleClickOutside: handleClickOutside,
96
99
  handleEnterKeydown: handleEnterKeydown,
@@ -35,7 +35,8 @@ function ExtensionWithPluginState(props) {
35
35
  isNodeNested = props.isNodeNested,
36
36
  setIsNodeHovered = props.setIsNodeHovered;
37
37
  var _ref = macroInteractionDesignFeatureFlags || {},
38
- showMacroInteractionDesignUpdates = _ref.showMacroInteractionDesignUpdates;
38
+ showMacroInteractionDesignUpdates = _ref.showMacroInteractionDesignUpdates,
39
+ showMacroButtonUpdates = _ref.showMacroButtonUpdates;
39
40
  var hasBody = ['bodiedExtension', 'multiBodiedExtension'].includes(node.type.name);
40
41
  var isMobile = editorAppearance === 'mobile';
41
42
  var hasChildren = !!children;
@@ -103,6 +104,7 @@ function ExtensionWithPluginState(props) {
103
104
  isNodeNested: isNodeNested,
104
105
  node: node,
105
106
  showMacroInteractionDesignUpdates: showMacroInteractionDesignUpdates,
107
+ showMacroButtonUpdates: showMacroButtonUpdates,
106
108
  customContainerStyles: customContainerStyles,
107
109
  setIsNodeHovered: setIsNodeHovered,
108
110
  isBodiedMacro: hasBody
@@ -20,7 +20,8 @@ var InlineExtension = function InlineExtension(props) {
20
20
  isNodeHovered = props.isNodeHovered,
21
21
  setIsNodeHovered = props.setIsNodeHovered;
22
22
  var _ref = macroInteractionDesignFeatureFlags || {},
23
- showMacroInteractionDesignUpdates = _ref.showMacroInteractionDesignUpdates;
23
+ showMacroInteractionDesignUpdates = _ref.showMacroInteractionDesignUpdates,
24
+ showMacroButtonUpdates = _ref.showMacroButtonUpdates;
24
25
  var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['width']),
25
26
  widthState = _useSharedPluginState.widthState;
26
27
  var hasChildren = !!children;
@@ -42,6 +43,7 @@ var InlineExtension = function InlineExtension(props) {
42
43
  isNodeSelected: isNodeSelected,
43
44
  isNodeHovered: isNodeHovered,
44
45
  showMacroInteractionDesignUpdates: showMacroInteractionDesignUpdates,
46
+ showMacroButtonUpdates: showMacroButtonUpdates,
45
47
  setIsNodeHovered: setIsNodeHovered
46
48
  }), jsx("div", {
47
49
  "data-testid": "inline-extension-wrapper"
@@ -1,33 +1,36 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  /** @jsx jsx */
2
- import { useCallback } from 'react';
3
+ import { Fragment } from 'react';
3
4
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
4
5
  import { css, jsx } from '@emotion/react';
5
6
  import classnames from 'classnames';
6
- import { N0, N30, N40, N500 } from '@atlaskit/theme/colors';
7
- var labelStyles = css({
7
+ import { defineMessages, useIntl } from 'react-intl-next';
8
+ import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
9
+ import { N0, N30, N40, N500, N800 } from '@atlaskit/theme/colors';
10
+ import Tooltip from '@atlaskit/tooltip';
11
+ var containerStyles = css({
12
+ textAlign: 'left',
13
+ zIndex: 1,
14
+ position: 'relative',
15
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
16
+ '&.bodied': {
17
+ marginTop: "var(--ds-space-300, 24px)"
18
+ }
19
+ });
20
+ var sharedLabelStyles = css({
8
21
  opacity: 0,
22
+ lineHeight: 1,
9
23
  display: 'inline-flex',
10
- width: 'max-content',
11
24
  justifyContent: 'left',
12
25
  position: 'absolute',
13
- // Unfortunately, these need to be these exact numbers - otherwise there will be a noticeable gap/overlap
26
+ width: 'max-content',
14
27
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
15
28
  top: '-19px',
16
29
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
17
- '&.inline': {
18
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
19
- top: '-18px',
20
- marginLeft: "var(--ds-space-150, 12px)"
21
- },
22
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
23
30
  '&.show-label': {
24
31
  cursor: 'pointer',
25
- background: "var(--ds-background-accent-gray-subtle-pressed, ".concat(N40, ")"),
26
- color: "var(--ds-text-subtle, ".concat(N500, ")"),
27
32
  opacity: 1
28
33
  },
29
- borderRadius: "var(--ds-border-radius, 3px)".concat(" ", "var(--ds-border-radius, 3px)", " 0 0"),
30
- lineHeight: 1,
31
34
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
32
35
  '&.nested': {
33
36
  // Need to add indent if the node is nested since we removed previous indentation styles to make it fit properly
@@ -35,26 +38,49 @@ var labelStyles = css({
35
38
  marginLeft: "var(--ds-space-150, 12px)"
36
39
  },
37
40
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
38
- '&.bodied-background': {
39
- background: "var(--ds-surface, ".concat(N0, ")")
40
- },
41
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
42
- '&.bodied-border': {
43
- boxShadow: "0 0 0 1px ".concat("var(--ds-border, ".concat(N30, ")"))
41
+ '&.inline': {
42
+ marginLeft: "var(--ds-space-150, 12px)",
43
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
44
+ top: '-18px'
44
45
  }
45
46
  });
47
+ var buttonLabelStyles = css({
48
+ alignItems: 'center',
49
+ borderRadius: "var(--ds-border-radius, 3px)",
50
+ paddingLeft: "var(--ds-space-050, 4px)",
51
+ paddingRight: "var(--ds-space-050, 4px)",
52
+ color: "var(--ds-text-subtle, ".concat(N800, ")"),
53
+ backgroundColor: "var(--ds-background-accent-gray-subtlest, ".concat(N30, ")")
54
+ });
55
+ var placeholderStyles = css({
56
+ height: "var(--ds-space-150, 12px)"
57
+ });
46
58
  var textStyles = css({
47
59
  fontSize: '14px',
48
60
  fontWeight: 'normal',
49
61
  padding: "var(--ds-space-025, 2px)".concat(" ", "var(--ds-space-050, 4px)")
50
62
  });
51
- var containerStyles = css({
52
- textAlign: 'left',
53
- zIndex: 1,
54
- position: 'relative',
63
+ var originalLabelStyles = css({
64
+ borderRadius: "var(--ds-border-radius, 3px)".concat(" ", "var(--ds-border-radius, 3px)", " 0 0"),
55
65
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
56
- '&.bodied': {
57
- marginTop: "var(--ds-space-300, 24px)"
66
+ '&.show-label': {
67
+ background: "var(--ds-background-accent-gray-subtle-pressed, ".concat(N40, ")"),
68
+ color: "var(--ds-text-subtle, ".concat(N500, ")")
69
+ },
70
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
71
+ '&.bodied-background': {
72
+ background: "var(--ds-surface, ".concat(N0, ")")
73
+ },
74
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
75
+ '&.bodied-border': {
76
+ boxShadow: "0 0 0 1px ".concat("var(--ds-border, ".concat(N30, ")"))
77
+ }
78
+ });
79
+ var i18n = defineMessages({
80
+ configure: {
81
+ id: 'editor-common-extensibility.macro.button.configure',
82
+ defaultMessage: 'Configure',
83
+ description: 'Text in tooltip that tells user they can configure the specific macro.'
58
84
  }
59
85
  });
60
86
  export var ExtensionLabel = function ExtensionLabel(_ref) {
@@ -64,7 +90,10 @@ export var ExtensionLabel = function ExtensionLabel(_ref) {
64
90
  customContainerStyles = _ref.customContainerStyles,
65
91
  isNodeNested = _ref.isNodeNested,
66
92
  setIsNodeHovered = _ref.setIsNodeHovered,
67
- isBodiedMacro = _ref.isBodiedMacro;
93
+ isBodiedMacro = _ref.isBodiedMacro,
94
+ showMacroButtonUpdates = _ref.showMacroButtonUpdates;
95
+ var intl = useIntl();
96
+ var tooltipText = "".concat(intl.formatMessage(i18n.configure), " ").concat(text);
68
97
  var containerClassNames = classnames({
69
98
  bodied: isBodiedMacro
70
99
  });
@@ -72,20 +101,10 @@ export var ExtensionLabel = function ExtensionLabel(_ref) {
72
101
  nested: isNodeNested,
73
102
  inline: extensionName === 'inlineExtension',
74
103
  bodied: isBodiedMacro,
75
- 'bodied-border': isBodiedMacro && !isNodeHovered,
76
- 'bodied-background': isBodiedMacro && !isNodeHovered,
104
+ 'bodied-border': isBodiedMacro && !isNodeHovered && !showMacroButtonUpdates,
105
+ 'bodied-background': isBodiedMacro && !isNodeHovered && !showMacroButtonUpdates,
77
106
  'show-label': isNodeHovered || isBodiedMacro
78
107
  });
79
- var handleMouseEnter = useCallback(function () {
80
- // If current node is hovered and the label is hovered,
81
- // consider the node as hovered so we can display the label for users to click on
82
- if (isNodeHovered) {
83
- setIsNodeHovered === null || setIsNodeHovered === void 0 || setIsNodeHovered(true);
84
- }
85
- }, [isNodeHovered, setIsNodeHovered]);
86
- var handleMouseLeave = useCallback(function () {
87
- setIsNodeHovered === null || setIsNodeHovered === void 0 || setIsNodeHovered(false);
88
- }, [setIsNodeHovered]);
89
108
  return jsx("div", {
90
109
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
91
110
  css: containerStyles
@@ -95,12 +114,35 @@ export var ExtensionLabel = function ExtensionLabel(_ref) {
95
114
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
96
115
  ,
97
116
  style: customContainerStyles,
98
- onMouseEnter: handleMouseEnter,
99
- onMouseLeave: handleMouseLeave,
117
+ onMouseOver: function onMouseOver() {
118
+ setIsNodeHovered === null || setIsNodeHovered === void 0 || setIsNodeHovered(true);
119
+ },
120
+ onMouseLeave: function onMouseLeave() {
121
+ setIsNodeHovered === null || setIsNodeHovered === void 0 || setIsNodeHovered(false);
122
+ },
100
123
  "data-testid": "new-lozenge-container"
101
- }, jsx("span", {
124
+ }, showMacroButtonUpdates ? jsx(Fragment, null, jsx(Tooltip, {
125
+ content: tooltipText,
126
+ position: "top"
127
+ }, function (tooltipProps) {
128
+ return jsx("span", _extends({
129
+ "data-testid": "new-lozenge-button"
130
+ }, tooltipProps, {
131
+ css: [sharedLabelStyles, buttonLabelStyles]
132
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
133
+ ,
134
+ className: labelClassNames
135
+ }), text, " ", jsx(PreferencesIcon, {
136
+ label: ""
137
+ }));
138
+ }), jsx("div", {
139
+ "data-testid": "placeholder",
140
+ css: placeholderStyles
141
+ })) : jsx("span", {
102
142
  "data-testid": "new-lozenge",
103
- css: labelStyles,
143
+ css: [sharedLabelStyles, originalLabelStyles]
144
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
145
+ ,
104
146
  className: labelClassNames
105
147
  }, jsx("span", {
106
148
  css: textStyles