@atlaskit/editor-common 94.4.0 → 94.5.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 (56) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/cjs/analytics/types/enums.js +3 -0
  3. package/dist/cjs/element-browser/components/ElementList/ElementList.js +2 -2
  4. package/dist/cjs/media/messages/caption.js +5 -0
  5. package/dist/cjs/monitoring/error.js +1 -1
  6. package/dist/cjs/styles/shared/headings.js +2 -2
  7. package/dist/cjs/styles/shared/paragraph.js +2 -2
  8. package/dist/cjs/ui/DropList/index.js +15 -10
  9. package/dist/cjs/ui/Emoji/index.js +17 -9
  10. package/dist/cjs/ui-menu/Dropdown/index.js +13 -7
  11. package/dist/cjs/ui-menu/DropdownMenu/index.js +11 -3
  12. package/dist/cjs/ui-react/index.js +10 -1
  13. package/dist/cjs/ui-react/with-react-editor-view-outer-listeners.js +24 -13
  14. package/dist/es2019/analytics/types/enums.js +3 -0
  15. package/dist/es2019/element-browser/components/ElementList/ElementList.js +2 -2
  16. package/dist/es2019/media/messages/caption.js +5 -0
  17. package/dist/es2019/monitoring/error.js +1 -1
  18. package/dist/es2019/styles/shared/headings.js +2 -2
  19. package/dist/es2019/styles/shared/paragraph.js +2 -2
  20. package/dist/es2019/ui/DropList/index.js +7 -2
  21. package/dist/es2019/ui/Emoji/index.js +10 -8
  22. package/dist/es2019/ui-menu/Dropdown/index.js +6 -5
  23. package/dist/es2019/ui-menu/DropdownMenu/index.js +12 -4
  24. package/dist/es2019/ui-react/index.js +1 -1
  25. package/dist/es2019/ui-react/with-react-editor-view-outer-listeners.js +23 -14
  26. package/dist/esm/analytics/types/enums.js +3 -0
  27. package/dist/esm/element-browser/components/ElementList/ElementList.js +2 -2
  28. package/dist/esm/media/messages/caption.js +5 -0
  29. package/dist/esm/monitoring/error.js +1 -1
  30. package/dist/esm/styles/shared/headings.js +2 -2
  31. package/dist/esm/styles/shared/paragraph.js +2 -2
  32. package/dist/esm/ui/DropList/index.js +15 -10
  33. package/dist/esm/ui/Emoji/index.js +14 -8
  34. package/dist/esm/ui-menu/Dropdown/index.js +14 -8
  35. package/dist/esm/ui-menu/DropdownMenu/index.js +12 -4
  36. package/dist/esm/ui-react/index.js +1 -1
  37. package/dist/esm/ui-react/with-react-editor-view-outer-listeners.js +23 -14
  38. package/dist/types/analytics/types/enums.d.ts +5 -2
  39. package/dist/types/analytics/types/index.d.ts +1 -1
  40. package/dist/types/analytics/types/media-events.d.ts +6 -2
  41. package/dist/types/media/messages/caption.d.ts +5 -0
  42. package/dist/types/ui/DropList/index.d.ts +6 -2
  43. package/dist/types/ui/Emoji/index.d.ts +3 -3
  44. package/dist/types/ui/index.d.ts +1 -1
  45. package/dist/types/ui-react/index.d.ts +1 -1
  46. package/dist/types/ui-react/with-react-editor-view-outer-listeners.d.ts +1 -0
  47. package/dist/types-ts4.5/analytics/types/enums.d.ts +5 -2
  48. package/dist/types-ts4.5/analytics/types/index.d.ts +1 -1
  49. package/dist/types-ts4.5/analytics/types/media-events.d.ts +6 -2
  50. package/dist/types-ts4.5/media/messages/caption.d.ts +5 -0
  51. package/dist/types-ts4.5/ui/DropList/index.d.ts +6 -2
  52. package/dist/types-ts4.5/ui/Emoji/index.d.ts +3 -3
  53. package/dist/types-ts4.5/ui/index.d.ts +1 -1
  54. package/dist/types-ts4.5/ui-react/index.d.ts +1 -1
  55. package/dist/types-ts4.5/ui-react/with-react-editor-view-outer-listeners.d.ts +1 -0
  56. package/package.json +9 -3
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import React, { PureComponent } from 'react';
4
- import { withReactEditorViewOuterListeners } from '../../ui-react';
4
+ import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '../../ui-react';
5
5
  import DropdownList from '../../ui/DropList';
6
6
  import Popup from '../../ui/Popup';
7
7
  import { ArrowKeyNavigationProvider } from '../ArrowKeyNavigationProvider';
@@ -14,7 +14,8 @@ import { ArrowKeyNavigationProvider } from '../ArrowKeyNavigationProvider';
14
14
  export class Dropdown extends PureComponent {
15
15
  constructor(props) {
16
16
  super(props);
17
- _defineProperty(this, "handleRef", target => {
17
+ _defineProperty(this, "handleRef", setOutsideClickTargetRef => target => {
18
+ setOutsideClickTargetRef(target);
18
19
  this.setState({
19
20
  target: target || undefined
20
21
  });
@@ -90,9 +91,9 @@ export class Dropdown extends PureComponent {
90
91
  trigger,
91
92
  isOpen
92
93
  } = this.props;
93
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
94
- ref: this.handleRef
95
- }, trigger), isOpen ? this.renderDropdown() : null);
94
+ return /*#__PURE__*/React.createElement(OutsideClickTargetRefContext.Consumer, null, setOutsideClickTargetRef => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
95
+ ref: this.handleRef(setOutsideClickTargetRef)
96
+ }, trigger), isOpen ? this.renderDropdown() : null));
96
97
  }
97
98
  }
98
99
  const DropdownWithOuterListeners = withReactEditorViewOuterListeners(Dropdown);
@@ -1,5 +1,5 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
3
  /**
4
4
  * @jsxRuntime classic
5
5
  * @jsx jsx
@@ -13,7 +13,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
13
13
  import Tooltip from '@atlaskit/tooltip';
14
14
  import { DropdownMenuSharedCssClassName } from '../../styles';
15
15
  import { KeyDownHandlerContext } from '../../ui-menu/ToolbarArrowKeyNavigationProvider';
16
- import { withReactEditorViewOuterListeners } from '../../ui-react';
16
+ import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '../../ui-react';
17
17
  import DropList from '../../ui/DropList';
18
18
  import Popup from '../../ui/Popup';
19
19
  import { ArrowKeyNavigationProvider } from '../ArrowKeyNavigationProvider';
@@ -74,7 +74,13 @@ const buttonStyles = (isActive, submenuActive) => {
74
74
  `; // The default focus-visible style is removed to ensure consistency across browsers
75
75
  }
76
76
  };
77
- const DropListWithOutsideListeners = withReactEditorViewOuterListeners(DropList);
77
+ const DropListWithOutsideClickTargetRef = props => {
78
+ const setOutsideClickTargetRef = React.useContext(OutsideClickTargetRefContext);
79
+ return jsx(DropList, _extends({
80
+ onDroplistRef: setOutsideClickTargetRef
81
+ }, props));
82
+ };
83
+ const DropListWithOutsideListeners = withReactEditorViewOuterListeners(DropListWithOutsideClickTargetRef);
78
84
 
79
85
  /**
80
86
  * Wrapper around @atlaskit/droplist which uses Popup and Portal to render
@@ -311,7 +317,9 @@ export function DropdownMenuItem({
311
317
  // From time to time we don't want to have any tabIndex on item wrapper
312
318
  // especially when we pass any interactive element as a item.content
313
319
  const tabIndex = item.wrapperTabIndex === null ? undefined : item.wrapperTabIndex || -1;
314
- const dropListItem = jsx("div", {
320
+ const dropListItem =
321
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
322
+ jsx("div", {
315
323
  css: () => buttonStyles(item.isActive, submenuActive),
316
324
  tabIndex: tabIndex,
317
325
  "aria-disabled": item.isDisabled ? 'true' : 'false',
@@ -1,2 +1,2 @@
1
1
  export { default as ReactEditorViewContext } from './ReactEditorViewContext';
2
- export { default as withReactEditorViewOuterListeners } from './with-react-editor-view-outer-listeners';
2
+ export { default as withReactEditorViewOuterListeners, OutsideClickTargetRefContext } from './with-react-editor-view-outer-listeners';
@@ -1,27 +1,29 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import React, { PureComponent, useEffect, useState } from 'react';
2
+ import React, { PureComponent, useCallback, useEffect, useRef, useState } from 'react';
3
3
  import ReactDOM from 'react-dom';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  import ReactEditorViewContext from './ReactEditorViewContext';
6
+ // Use this context to pass in the reference of the element that should be considered as the outside click target
7
+ // The outside click target is the element that should be clicked outside of to trigger the `handleClickOutside` event
8
+ export const OutsideClickTargetRefContext = /*#__PURE__*/React.createContext(() => {});
5
9
 
6
- // This needs exporting to be used alongisde `withReactEditorViewOuterListeners`
10
+ // This needs exporting to be used alongside `withReactEditorViewOuterListeners`
7
11
 
8
12
  class WithOutsideClick extends PureComponent {
9
13
  constructor(...args) {
10
14
  super(...args);
11
15
  _defineProperty(this, "handleClick", evt => {
12
- if (!this.props.isActiveComponent) {
16
+ if (!this.props.isActiveComponent || !this.props.handleClickOutside) {
13
17
  return;
14
18
  }
15
- const domNode = ReactDOM.findDOMNode(this); // eslint-disable-line react/no-find-dom-node
19
+ const domNode = fg('platform_editor_replace_finddomnode_in_common') ? this.props.outsideClickTargetRef.current : ReactDOM.findDOMNode(this);
16
20
  if (!domNode || evt.target instanceof Node && !domNode.contains(evt.target)) {
17
- if (this.props.handleClickOutside) {
18
- var _this$props$editorVie;
19
- this.props.handleClickOutside(evt);
20
- // When the menus are closed by clicking outside the focus is set on editor.
21
- if (!((_this$props$editorVie = this.props.editorView) !== null && _this$props$editorVie !== void 0 && _this$props$editorVie.hasFocus())) {
22
- var _this$props$editorVie2;
23
- (_this$props$editorVie2 = this.props.editorView) === null || _this$props$editorVie2 === void 0 ? void 0 : _this$props$editorVie2.focus();
24
- }
21
+ var _this$props$editorVie;
22
+ this.props.handleClickOutside(evt);
23
+ // When the menus are closed by clicking outside the focus is set on editor.
24
+ if (!((_this$props$editorVie = this.props.editorView) !== null && _this$props$editorVie !== void 0 && _this$props$editorVie.hasFocus())) {
25
+ var _this$props$editorVie2;
26
+ (_this$props$editorVie2 = this.props.editorView) === null || _this$props$editorVie2 === void 0 ? void 0 : _this$props$editorVie2.focus();
25
27
  }
26
28
  }
27
29
  });
@@ -79,6 +81,10 @@ export default function withReactEditorViewOuterListeners(Component) {
79
81
  }) => {
80
82
  const isActiveProp = hasIsOpen(props) ? props.isOpen : true;
81
83
  const [isActiveComponent, setActiveComponent] = useState(false);
84
+ const outsideClickTargetRef = useRef(null);
85
+ const setOutsideClickTargetRef = useCallback(el => {
86
+ outsideClickTargetRef.current = el;
87
+ }, [outsideClickTargetRef]);
82
88
  useEffect(() => {
83
89
  requestAnimationFrame(() => {
84
90
  setActiveComponent(isActiveProp);
@@ -88,16 +94,19 @@ export default function withReactEditorViewOuterListeners(Component) {
88
94
  editorView,
89
95
  popupsMountPoint,
90
96
  editorRef
91
- }) => /*#__PURE__*/React.createElement(WithOutsideClick, {
97
+ }) => /*#__PURE__*/React.createElement(OutsideClickTargetRefContext.Provider, {
98
+ value: setOutsideClickTargetRef
99
+ }, /*#__PURE__*/React.createElement(WithOutsideClick, {
92
100
  editorView: editorView,
93
101
  editorRef: editorRef,
94
102
  targetRef: props.targetRef,
103
+ outsideClickTargetRef: outsideClickTargetRef,
95
104
  popupsMountPoint: popupsMountPoint,
96
105
  isActiveComponent: isActiveComponent,
97
106
  handleClickOutside: handleClickOutside,
98
107
  handleEnterKeydown: handleEnterKeydown,
99
108
  handleEscapeKeydown: handleEscapeKeydown,
100
109
  closeOnTab: closeOnTab
101
- }, /*#__PURE__*/React.createElement(Component, props)));
110
+ }, /*#__PURE__*/React.createElement(Component, props))));
102
111
  };
103
112
  }
@@ -35,6 +35,7 @@ export var ACTION = /*#__PURE__*/function (ACTION) {
35
35
  ACTION["DISMISSED"] = "dismissed";
36
36
  ACTION["DISPATCHED_INVALID_TRANSACTION"] = "dispatchedInvalidTransaction";
37
37
  ACTION["DISPATCHED_VALID_TRANSACTION"] = "dispatchedValidTransaction";
38
+ ACTION["DOUBLE_CLICKED"] = "doubleClicked";
38
39
  ACTION["DRAGGED"] = "dragged";
39
40
  ACTION["EDITED"] = "edited";
40
41
  ACTION["EDITOR_CRASHED"] = "unhandledErrorCaught";
@@ -180,6 +181,7 @@ export var INPUT_METHOD = /*#__PURE__*/function (INPUT_METHOD) {
180
181
  INPUT_METHOD["TABLE_CONTEXT_MENU"] = "tableContextMenu";
181
182
  INPUT_METHOD["MOUSE"] = "mouse";
182
183
  INPUT_METHOD["BROWSER"] = "browser";
184
+ INPUT_METHOD["DOUBLE_CLICK"] = "doubleClick";
183
185
  return INPUT_METHOD;
184
186
  }({});
185
187
  export var INSERT_MEDIA_VIA = /*#__PURE__*/function (INSERT_MEDIA_VIA) {
@@ -257,6 +259,7 @@ export var ACTION_SUBJECT = /*#__PURE__*/function (ACTION_SUBJECT) {
257
259
  ACTION_SUBJECT["CONTEXT_MENU"] = "contextMenu";
258
260
  ACTION_SUBJECT["INLINE_DIALOG"] = "inlineDialog";
259
261
  ACTION_SUBJECT["ENGAGEMENT_PLATFORM"] = "engagementPlatform";
262
+ ACTION_SUBJECT["MEDIA_VIEWER"] = "mediaViewer";
260
263
  return ACTION_SUBJECT;
261
264
  }({});
262
265
  export var ACTION_SUBJECT_ID = /*#__PURE__*/function (ACTION_SUBJECT_ID) {
@@ -17,8 +17,8 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
17
17
  import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
18
18
  import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
19
19
  import { ButtonItem } from '@atlaskit/menu';
20
+ import { fg } from '@atlaskit/platform-feature-flags';
20
21
  import { Stack, Text } from '@atlaskit/primitives';
21
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
22
  import Tooltip from '@atlaskit/tooltip';
23
23
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '../../../analytics';
24
24
  import { IconFallback } from '../../../quick-insert';
@@ -291,7 +291,7 @@ var ItemContent = /*#__PURE__*/memo(function (_ref7) {
291
291
  var title = _ref7.title,
292
292
  description = _ref7.description,
293
293
  keyshortcut = _ref7.keyshortcut;
294
- if (editorExperiment('typography_migration_ugc', true)) {
294
+ if (fg('platform_editor_typography_ugc')) {
295
295
  return (
296
296
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
297
297
  jsx("div", {
@@ -4,5 +4,10 @@ export var captionMessages = defineMessages({
4
4
  id: 'fabric.editor.captionPlaceholder',
5
5
  defaultMessage: 'Add a caption',
6
6
  description: 'Placeholder description for an empty (new) caption in the editor'
7
+ },
8
+ placeholderWithDoubleClickPrompt: {
9
+ id: 'fabric.editor.captionPlaceholderWithDoubleClickPrompt',
10
+ defaultMessage: 'Add a caption - double-click to preview',
11
+ description: 'Placeholder description to prompt users to add a caption and double click media to preview'
7
12
  }
8
13
  });
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { isFedRamp } from './environment';
8
8
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
9
9
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
10
- var packageVersion = "94.4.0";
10
+ var packageVersion = "94.5.0";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // TODO: Sanitise the URL instead of just removing it
@@ -9,7 +9,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
10
10
  import { css } from '@emotion/react';
11
11
  import { fg } from '@atlaskit/platform-feature-flags';
12
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
12
  import editorUGCToken from '../../ugc-tokens/get-editor-ugc-token';
14
13
  var headingWithAlignmentStyles = function headingWithAlignmentStyles() {
15
14
  return (
@@ -48,7 +47,7 @@ var headingWithAlignmentStyles = function headingWithAlignmentStyles() {
48
47
  // @see typography spreadsheet: https://docs.google.com/spreadsheets/d/1iYusRGCT4PoPfvxbJ8NrgjtfFgXLm5lpDWXzjua1W2E/edit#gid=93913128
49
48
  // text sizing prototype: http://proto/fabricrender/
50
49
  export var headingsSharedStyles = function headingsSharedStyles(typographyTheme) {
51
- var isADSTokenMigrationEnabled = editorExperiment('typography_migration_ugc', true);
50
+ var isADSTokenMigrationEnabled = fg('platform_editor_typography_ugc');
52
51
  if (isADSTokenMigrationEnabled) {
53
52
  return css(_objectSpread({
54
53
  '& h1': {
@@ -72,6 +71,7 @@ export var headingsSharedStyles = function headingsSharedStyles(typographyTheme)
72
71
  },
73
72
  '& h5': {
74
73
  font: editorUGCToken('editor.font.heading.h5', typographyTheme),
74
+ marginTop: '1.667em',
75
75
  textTransform: 'none'
76
76
  },
77
77
  '& h6': {
@@ -5,12 +5,12 @@
5
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
6
  import { css } from '@emotion/react';
7
7
  import { akEditorLineHeight, blockNodesVerticalMargin } from '@atlaskit/editor-shared-styles';
8
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import editorUGCToken from '../../ugc-tokens/get-editor-ugc-token';
10
10
 
11
11
  // @see typography spreadsheet: https://docs.google.com/spreadsheets/d/1iYusRGCT4PoPfvxbJ8NrgjtfFgXLm5lpDWXzjua1W2E/edit#gid=93913128
12
12
  export var paragraphSharedStyles = function paragraphSharedStyles(typographyTheme) {
13
- return editorExperiment('typography_migration_ugc', true) ? css({
13
+ return fg('platform_editor_typography_ugc') ? css({
14
14
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
15
15
  '& p': {
16
16
  font: editorUGCToken('editor.font.body', typographyTheme),
@@ -21,7 +21,7 @@ import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext'
21
21
  import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "94.4.0";
24
+ var packageVersion = "94.5.0";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var DropList = /*#__PURE__*/function (_Component) {
@@ -129,6 +129,10 @@ var DropList = /*#__PURE__*/function (_Component) {
129
129
  ref.focus();
130
130
  }
131
131
  });
132
+ _defineProperty(_assertThisInitialized(_this), "handleDroplistRef", function (ref) {
133
+ var _this$props$onDroplis, _this$props;
134
+ (_this$props$onDroplis = (_this$props = _this.props).onDroplistRef) === null || _this$props$onDroplis === void 0 || _this$props$onDroplis.call(_this$props, ref);
135
+ });
132
136
  _defineProperty(_assertThisInitialized(_this), "handleTriggerRef", function (ref) {
133
137
  _this.triggerRef = ref;
134
138
  });
@@ -137,14 +141,14 @@ var DropList = /*#__PURE__*/function (_Component) {
137
141
  _createClass(DropList, [{
138
142
  key: "render",
139
143
  value: function render() {
140
- var _this$props = this.props,
141
- children = _this$props.children,
142
- isOpen = _this$props.isOpen,
143
- position = _this$props.position,
144
- trigger = _this$props.trigger,
145
- onPositioned = _this$props.onPositioned,
146
- testId = _this$props.testId,
147
- id = _this$props.id;
144
+ var _this$props2 = this.props,
145
+ children = _this$props2.children,
146
+ isOpen = _this$props2.isOpen,
147
+ position = _this$props2.position,
148
+ trigger = _this$props2.trigger,
149
+ onPositioned = _this$props2.onPositioned,
150
+ testId = _this$props2.testId,
151
+ id = _this$props2.id;
148
152
  var layerContent = isOpen ? jsx("div", {
149
153
  css: this.menuWrapper,
150
154
  "data-role": "droplistContent",
@@ -154,7 +158,8 @@ var DropList = /*#__PURE__*/function (_Component) {
154
158
  role: "presentation"
155
159
  }, children) : null;
156
160
  return jsx("div", {
157
- css: this.wrapperStyles
161
+ css: this.wrapperStyles,
162
+ ref: this.handleDroplistRef
158
163
  }, jsx(Layer, {
159
164
  content: layerContent,
160
165
  offset: dropOffset,
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { ResourcedEmoji } from '@atlaskit/emoji/element';
3
3
  var EmojiNodeFunctional = function EmojiNodeFunctional(props) {
4
4
  var _resourceConfig$optim;
@@ -10,6 +10,16 @@ var EmojiNodeFunctional = function EmojiNodeFunctional(props) {
10
10
  showTooltip = props.showTooltip,
11
11
  resourceConfig = props.resourceConfig,
12
12
  emojiProvider = props.emojiProvider;
13
+ var emojiId = useMemo(function () {
14
+ return {
15
+ shortName: shortName,
16
+ id: id,
17
+ fallback: fallback
18
+ };
19
+ }, [shortName, id, fallback]);
20
+ var emojiProviderResolver = useMemo(function () {
21
+ return Promise.resolve(emojiProvider);
22
+ }, [emojiProvider]);
13
23
  if (allowTextFallback && !emojiProvider) {
14
24
  return /*#__PURE__*/React.createElement("span", {
15
25
  "data-emoji-id": id,
@@ -21,12 +31,8 @@ var EmojiNodeFunctional = function EmojiNodeFunctional(props) {
21
31
  return null;
22
32
  }
23
33
  return /*#__PURE__*/React.createElement(ResourcedEmoji, {
24
- emojiId: {
25
- id: id,
26
- fallback: fallback,
27
- shortName: shortName
28
- },
29
- emojiProvider: Promise.resolve(emojiProvider),
34
+ emojiId: emojiId,
35
+ emojiProvider: emojiProviderResolver,
30
36
  showTooltip: showTooltip,
31
37
  fitToHeight: fitToHeight,
32
38
  optimistic: true,
@@ -41,4 +47,4 @@ var EmojiNodeFunctional = function EmojiNodeFunctional(props) {
41
47
  var EmojiNode = function EmojiNode(props) {
42
48
  return /*#__PURE__*/React.createElement(EmojiNodeFunctional, props);
43
49
  };
44
- export default EmojiNode;
50
+ export default /*#__PURE__*/React.memo(EmojiNode);
@@ -9,7 +9,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
9
  function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
10
10
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
11
  import React, { PureComponent } from 'react';
12
- import { withReactEditorViewOuterListeners } from '../../ui-react';
12
+ import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '../../ui-react';
13
13
  import DropdownList from '../../ui/DropList';
14
14
  import Popup from '../../ui/Popup';
15
15
  import { ArrowKeyNavigationProvider } from '../ArrowKeyNavigationProvider';
@@ -26,10 +26,13 @@ export var Dropdown = /*#__PURE__*/function (_PureComponent) {
26
26
  var _this;
27
27
  _classCallCheck(this, Dropdown);
28
28
  _this = _super.call(this, props);
29
- _defineProperty(_assertThisInitialized(_this), "handleRef", function (target) {
30
- _this.setState({
31
- target: target || undefined
32
- });
29
+ _defineProperty(_assertThisInitialized(_this), "handleRef", function (setOutsideClickTargetRef) {
30
+ return function (target) {
31
+ setOutsideClickTargetRef(target);
32
+ _this.setState({
33
+ target: target || undefined
34
+ });
35
+ };
33
36
  });
34
37
  _defineProperty(_assertThisInitialized(_this), "updatePopupPlacement", function (placement) {
35
38
  _this.setState({
@@ -101,12 +104,15 @@ export var Dropdown = /*#__PURE__*/function (_PureComponent) {
101
104
  }, {
102
105
  key: "render",
103
106
  value: function render() {
107
+ var _this2 = this;
104
108
  var _this$props2 = this.props,
105
109
  trigger = _this$props2.trigger,
106
110
  isOpen = _this$props2.isOpen;
107
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
108
- ref: this.handleRef
109
- }, trigger), isOpen ? this.renderDropdown() : null);
111
+ return /*#__PURE__*/React.createElement(OutsideClickTargetRefContext.Consumer, null, function (setOutsideClickTargetRef) {
112
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
113
+ ref: _this2.handleRef(setOutsideClickTargetRef)
114
+ }, trigger), isOpen ? _this2.renderDropdown() : null);
115
+ });
110
116
  }
111
117
  }]);
112
118
  return Dropdown;
@@ -1,7 +1,6 @@
1
1
  import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- import _extends from "@babel/runtime/helpers/extends";
5
4
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
6
5
  import _createClass from "@babel/runtime/helpers/createClass";
7
6
  import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
@@ -9,6 +8,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
9
8
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
10
9
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
11
10
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
11
+ import _extends from "@babel/runtime/helpers/extends";
12
12
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
13
13
  var _excluded = ["children"];
14
14
  var _templateObject, _templateObject2;
@@ -29,7 +29,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
29
29
  import Tooltip from '@atlaskit/tooltip';
30
30
  import { DropdownMenuSharedCssClassName } from '../../styles';
31
31
  import { KeyDownHandlerContext } from '../../ui-menu/ToolbarArrowKeyNavigationProvider';
32
- import { withReactEditorViewOuterListeners } from '../../ui-react';
32
+ import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners } from '../../ui-react';
33
33
  import DropList from '../../ui/DropList';
34
34
  import Popup from '../../ui/Popup';
35
35
  import { ArrowKeyNavigationProvider } from '../ArrowKeyNavigationProvider';
@@ -57,7 +57,13 @@ var buttonStyles = function buttonStyles(isActive, submenuActive) {
57
57
  return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n\t\t\t> span:hover[aria-disabled='false'] {\n\t\t\t\tcolor: ", ";\n\t\t\t\tbackground-color: ", ";\n\t\t\t}\n\t\t\t", "\n\t\t\t> span[aria-disabled='true'] {\n\t\t\t\tcolor: ", ";\n\t\t\t}\n\t\t\t:focus > span[aria-disabled='false'] {\n\t\t\t\t", ";\n\t\t\t}\n\t\t\t:focus-visible,\n\t\t\t:focus-visible > span[aria-disabled='false'] {\n\t\t\t\toutline: none;\n\t\t\t}\n\t\t"])), "var(--ds-text, #172B4D)", "var(--ds-background-neutral-subtle-hovered, rgb(244, 245, 247))", !submenuActive && "\n\t\t\t\t\t> span:active[aria-disabled='false'] {\n\t\t\t\t\t\tbackground-color: ".concat("var(--ds-background-neutral-subtle-pressed, rgb(179, 212, 255))", ";\n\t\t\t\t\t}"), "var(--ds-text-disabled, #091E424F)", focusedMenuItemStyle); // The default focus-visible style is removed to ensure consistency across browsers
58
58
  }
59
59
  };
60
- var DropListWithOutsideListeners = withReactEditorViewOuterListeners(DropList);
60
+ var DropListWithOutsideClickTargetRef = function DropListWithOutsideClickTargetRef(props) {
61
+ var setOutsideClickTargetRef = React.useContext(OutsideClickTargetRefContext);
62
+ return jsx(DropList, _extends({
63
+ onDroplistRef: setOutsideClickTargetRef
64
+ }, props));
65
+ };
66
+ var DropListWithOutsideListeners = withReactEditorViewOuterListeners(DropListWithOutsideClickTargetRef);
61
67
 
62
68
  /**
63
69
  * Wrapper around @atlaskit/droplist which uses Popup and Portal to render
@@ -305,7 +311,9 @@ export function DropdownMenuItem(_ref) {
305
311
  // From time to time we don't want to have any tabIndex on item wrapper
306
312
  // especially when we pass any interactive element as a item.content
307
313
  var tabIndex = item.wrapperTabIndex === null ? undefined : item.wrapperTabIndex || -1;
308
- var dropListItem = jsx("div", {
314
+ var dropListItem =
315
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
316
+ jsx("div", {
309
317
  css: function css() {
310
318
  return buttonStyles(item.isActive, submenuActive);
311
319
  },
@@ -1,2 +1,2 @@
1
1
  export { default as ReactEditorViewContext } from './ReactEditorViewContext';
2
- export { default as withReactEditorViewOuterListeners } from './with-react-editor-view-outer-listeners';
2
+ export { default as withReactEditorViewOuterListeners, OutsideClickTargetRefContext } from './with-react-editor-view-outer-listeners';
@@ -10,11 +10,15 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
10
  var _excluded = ["handleClickOutside", "handleEnterKeydown", "handleEscapeKeydown", "closeOnTab"];
11
11
  function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
12
12
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
- import React, { PureComponent, useEffect, useState } from 'react';
13
+ import React, { PureComponent, useCallback, useEffect, useRef, useState } from 'react';
14
14
  import ReactDOM from 'react-dom';
15
+ import { fg } from '@atlaskit/platform-feature-flags';
15
16
  import ReactEditorViewContext from './ReactEditorViewContext';
17
+ // Use this context to pass in the reference of the element that should be considered as the outside click target
18
+ // The outside click target is the element that should be clicked outside of to trigger the `handleClickOutside` event
19
+ export var OutsideClickTargetRefContext = /*#__PURE__*/React.createContext(function () {});
16
20
 
17
- // This needs exporting to be used alongisde `withReactEditorViewOuterListeners`
21
+ // This needs exporting to be used alongside `withReactEditorViewOuterListeners`
18
22
  var WithOutsideClick = /*#__PURE__*/function (_PureComponent) {
19
23
  _inherits(WithOutsideClick, _PureComponent);
20
24
  var _super = _createSuper(WithOutsideClick);
@@ -26,19 +30,17 @@ var WithOutsideClick = /*#__PURE__*/function (_PureComponent) {
26
30
  }
27
31
  _this = _super.call.apply(_super, [this].concat(args));
28
32
  _defineProperty(_assertThisInitialized(_this), "handleClick", function (evt) {
29
- if (!_this.props.isActiveComponent) {
33
+ if (!_this.props.isActiveComponent || !_this.props.handleClickOutside) {
30
34
  return;
31
35
  }
32
- var domNode = ReactDOM.findDOMNode(_assertThisInitialized(_this)); // eslint-disable-line react/no-find-dom-node
36
+ var domNode = fg('platform_editor_replace_finddomnode_in_common') ? _this.props.outsideClickTargetRef.current : ReactDOM.findDOMNode(_assertThisInitialized(_this));
33
37
  if (!domNode || evt.target instanceof Node && !domNode.contains(evt.target)) {
34
- if (_this.props.handleClickOutside) {
35
- var _this$props$editorVie;
36
- _this.props.handleClickOutside(evt);
37
- // When the menus are closed by clicking outside the focus is set on editor.
38
- if (!((_this$props$editorVie = _this.props.editorView) !== null && _this$props$editorVie !== void 0 && _this$props$editorVie.hasFocus())) {
39
- var _this$props$editorVie2;
40
- (_this$props$editorVie2 = _this.props.editorView) === null || _this$props$editorVie2 === void 0 || _this$props$editorVie2.focus();
41
- }
38
+ var _this$props$editorVie;
39
+ _this.props.handleClickOutside(evt);
40
+ // When the menus are closed by clicking outside the focus is set on editor.
41
+ if (!((_this$props$editorVie = _this.props.editorView) !== null && _this$props$editorVie !== void 0 && _this$props$editorVie.hasFocus())) {
42
+ var _this$props$editorVie2;
43
+ (_this$props$editorVie2 = _this.props.editorView) === null || _this$props$editorVie2 === void 0 || _this$props$editorVie2.focus();
42
44
  }
43
45
  }
44
46
  });
@@ -107,6 +109,10 @@ export default function withReactEditorViewOuterListeners(Component) {
107
109
  _useState2 = _slicedToArray(_useState, 2),
108
110
  isActiveComponent = _useState2[0],
109
111
  setActiveComponent = _useState2[1];
112
+ var outsideClickTargetRef = useRef(null);
113
+ var setOutsideClickTargetRef = useCallback(function (el) {
114
+ outsideClickTargetRef.current = el;
115
+ }, [outsideClickTargetRef]);
110
116
  useEffect(function () {
111
117
  requestAnimationFrame(function () {
112
118
  setActiveComponent(isActiveProp);
@@ -116,17 +122,20 @@ export default function withReactEditorViewOuterListeners(Component) {
116
122
  var editorView = _ref2.editorView,
117
123
  popupsMountPoint = _ref2.popupsMountPoint,
118
124
  editorRef = _ref2.editorRef;
119
- return /*#__PURE__*/React.createElement(WithOutsideClick, {
125
+ return /*#__PURE__*/React.createElement(OutsideClickTargetRefContext.Provider, {
126
+ value: setOutsideClickTargetRef
127
+ }, /*#__PURE__*/React.createElement(WithOutsideClick, {
120
128
  editorView: editorView,
121
129
  editorRef: editorRef,
122
130
  targetRef: props.targetRef,
131
+ outsideClickTargetRef: outsideClickTargetRef,
123
132
  popupsMountPoint: popupsMountPoint,
124
133
  isActiveComponent: isActiveComponent,
125
134
  handleClickOutside: handleClickOutside,
126
135
  handleEnterKeydown: handleEnterKeydown,
127
136
  handleEscapeKeydown: handleEscapeKeydown,
128
137
  closeOnTab: closeOnTab
129
- }, /*#__PURE__*/React.createElement(Component, props));
138
+ }, /*#__PURE__*/React.createElement(Component, props)));
130
139
  });
131
140
  };
132
141
  }
@@ -37,6 +37,7 @@ export declare enum ACTION {
37
37
  DISMISSED = "dismissed",
38
38
  DISPATCHED_INVALID_TRANSACTION = "dispatchedInvalidTransaction",
39
39
  DISPATCHED_VALID_TRANSACTION = "dispatchedValidTransaction",
40
+ DOUBLE_CLICKED = "doubleClicked",
40
41
  DRAGGED = "dragged",
41
42
  EDITED = "edited",
42
43
  EDITOR_CRASHED = "unhandledErrorCaught",
@@ -185,7 +186,8 @@ export declare enum INPUT_METHOD {
185
186
  DATASOURCE = "datasource_config",
186
187
  TABLE_CONTEXT_MENU = "tableContextMenu",
187
188
  MOUSE = "mouse",
188
- BROWSER = "browser"
189
+ BROWSER = "browser",
190
+ DOUBLE_CLICK = "doubleClick"
189
191
  }
190
192
  export declare enum INSERT_MEDIA_VIA {
191
193
  LOCAL_UPLOAD = "localUpload",
@@ -259,7 +261,8 @@ export declare enum ACTION_SUBJECT {
259
261
  ELEMENT = "element",
260
262
  CONTEXT_MENU = "contextMenu",
261
263
  INLINE_DIALOG = "inlineDialog",
262
- ENGAGEMENT_PLATFORM = "engagementPlatform"
264
+ ENGAGEMENT_PLATFORM = "engagementPlatform",
265
+ MEDIA_VIEWER = "mediaViewer"
263
266
  }
264
267
  export declare enum ACTION_SUBJECT_ID {
265
268
  ACTION = "action",
@@ -12,7 +12,7 @@ export { CHANGE_ALIGNMENT_REASON, TABLE_ACTION, TABLE_BREAKOUT, TABLE_OVERFLOW_C
12
12
  export type { TableEventPayload, OverflowStateInfo } from './table-events';
13
13
  export { PasteContents, PasteSources, PasteTypes } from './paste-events';
14
14
  export type { PASTE_ACTION_SUBJECT_ID, PasteContent, PasteEventPayload, PasteSource, PasteType, } from './paste-events';
15
- export type { MediaSwitchType, MediaAltTextActionType, MediaEventPayload, MediaLinkAEP, CaptionTrackAction, MediaResizeTrackAction, MediaInputResizeTrackAction, } from './media-events';
15
+ export type { MediaSwitchType, MediaAltTextActionType, MediaEventPayload, MediaLinkAEP, CaptionTrackAction, MediaResizeTrackAction, MediaInputResizeTrackAction, MediaViewerEventAction, } from './media-events';
16
16
  export type { MoveContentEventPayload } from './move-content-events';
17
17
  export type { DispatchAnalyticsEvent } from './dispatch-analytics-event';
18
18
  export { DELETE_DIRECTION, LIST_TEXT_SCENARIOS, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST, OUTDENT_SCENARIOS, } from './list-events';
@@ -1,6 +1,6 @@
1
1
  import type { RichMediaLayout } from '@atlaskit/adf-schema';
2
2
  import type { GuidelineTypes, WidthTypes } from '../../guideline/types';
3
- import type { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID } from './enums';
3
+ import type { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD } from './enums';
4
4
  import type { EventInput } from './type-ahead';
5
5
  import type { ChangeTypeAEP, TrackAEP, UIAEP } from './utils';
6
6
  type MediaBorderActionType = ACTION.UPDATED | ACTION.ADDED | ACTION.DELETED;
@@ -37,6 +37,10 @@ type ChangeMediaAEP = ChangeTypeAEP<ACTION_SUBJECT.MEDIA, undefined, {
37
37
  newType: MediaSwitchType;
38
38
  previousType: MediaSwitchType;
39
39
  }, undefined>;
40
+ export type MediaViewerEventAction = UIAEP<ACTION.OPENED, ACTION_SUBJECT.MEDIA_VIEWER, ACTION_SUBJECT_ID.MEDIA, {
41
+ nodeType: string;
42
+ inputMethod: INPUT_METHOD.DOUBLE_CLICK;
43
+ }, undefined>;
40
44
  export type MediaAltTextActionType = ACTION.ADDED | ACTION.CLOSED | ACTION.EDITED | ACTION.CLEARED | ACTION.OPENED;
41
- export type MediaEventPayload = MediaLinkAEP | MediaAltTextAction | MediaUIAction | MediaResizeTrackAction | MediaInputResizeTrackAction | MediaBorderTrackAction | CaptionTrackAction | ChangeMediaAEP;
45
+ export type MediaEventPayload = MediaLinkAEP | MediaAltTextAction | MediaUIAction | MediaResizeTrackAction | MediaInputResizeTrackAction | MediaBorderTrackAction | CaptionTrackAction | ChangeMediaAEP | MediaViewerEventAction;
42
46
  export {};
@@ -4,4 +4,9 @@ export declare const captionMessages: {
4
4
  defaultMessage: string;
5
5
  description: string;
6
6
  };
7
+ placeholderWithDoubleClickPrompt: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
7
12
  };