@atlaskit/editor-plugin-insert-block 2.4.1 → 2.4.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-insert-block
2
2
 
3
+ ## 2.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#155668](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/155668)
8
+ [`f948f63ced742`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f948f63ced742) -
9
+ We are testing replacing findDOMNode with an explicit ref behind a feature flag. If this fix is
10
+ successful it will be available in a later release.
11
+ - Updated dependencies
12
+
13
+ ## 2.4.2
14
+
15
+ ### Patch Changes
16
+
17
+ - [#156556](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/156556)
18
+ [`fa4db989cfa70`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fa4db989cfa70) -
19
+ [HOT-112603] Reduce memory leak footage by using WeakRef to store HTML element
20
+
3
21
  ## 2.4.1
4
22
 
5
23
  ### Patch Changes
@@ -230,9 +230,11 @@ var flexWrapperStyles = (0, _react2.css)({
230
230
  overflow: 'hidden'
231
231
  });
232
232
  var FlexWrapper = function FlexWrapper(props) {
233
+ var setOutsideClickTargetRef = (0, _react.useContext)(_uiReact.OutsideClickTargetRefContext);
233
234
  var children = props.children,
234
235
  divProps = (0, _objectWithoutProperties2.default)(props, _excluded);
235
236
  return (0, _react2.jsx)("div", (0, _extends2.default)({
237
+ ref: setOutsideClickTargetRef,
236
238
  css: flexWrapperStyles
237
239
  }, divProps), children);
238
240
  };
@@ -15,6 +15,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
15
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
17
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
18
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
18
19
  var _react = _interopRequireDefault(require("react"));
19
20
  var _react2 = require("@emotion/react");
20
21
  var _reactIntlNext = require("react-intl-next");
@@ -53,13 +54,19 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
53
54
  var isDetachedElement = function isDetachedElement(el) {
54
55
  return !document.body.contains(el);
55
56
  };
56
- var EmojiPickerWithListeners = (0, _uiReact.withReactEditorViewOuterListeners)(_picker.EmojiPicker);
57
57
  var TABLE_SELECTOR_STRING = 'table selector';
58
58
 
59
59
  // TODO: Jenga team will create a component for a split button using this css
60
60
  var getHoverStyles = function getHoverStyles(selector) {
61
61
  return "&:hover ".concat(selector, " {\n background: ", "var(--ds-background-neutral-subtle-hovered, ".concat(colors.N20A, ")"), ";\n\n &:hover {\n background: ", "var(--ds-background-neutral-hovered, ".concat(colors.N30A, ")"), ";\n }\n }");
62
62
  };
63
+ var EmojiPicker = function EmojiPicker(props) {
64
+ var setOutsideClickTargetRef = _react.default.useContext(_uiReact.OutsideClickTargetRefContext);
65
+ return (0, _react2.jsx)(_picker.EmojiPicker, (0, _extends2.default)({
66
+ onPickerRef: setOutsideClickTargetRef
67
+ }, props));
68
+ };
69
+ var EmojiPickerWithListeners = (0, _uiReact.withReactEditorViewOuterListeners)(EmojiPicker);
63
70
  var tableButtonWrapper = exports.tableButtonWrapper = function tableButtonWrapper(_ref) {
64
71
  var isTableSelectorOpen = _ref.isTableSelectorOpen,
65
72
  isButtonDisabled = _ref.isButtonDisabled;
@@ -125,7 +132,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
125
132
  });
126
133
  if ((event === null || event === void 0 ? void 0 : event.key) === 'Escape') {
127
134
  var _ref2;
128
- (_ref2 = _this.plusButtonRef || _this.dropdownButtonRef) === null || _ref2 === void 0 || _ref2.focus();
135
+ (_ref2 = _this.plusButtonRef || _this.dropdownButtonRef) === null || _ref2 === void 0 || (_ref2 = _ref2.deref()) === null || _ref2 === void 0 || _ref2.focus();
129
136
  }
130
137
  });
131
138
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "toggleEmojiPicker", function () {
@@ -154,7 +161,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
154
161
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleEmojiPressEscape", function () {
155
162
  var _this$emojiButtonRef;
156
163
  _this.toggleEmojiPicker(_analytics.INPUT_METHOD.KEYBOARD);
157
- (_this$emojiButtonRef = _this.emojiButtonRef) === null || _this$emojiButtonRef === void 0 || _this$emojiButtonRef.focus();
164
+ (_this$emojiButtonRef = _this.emojiButtonRef) === null || _this$emojiButtonRef === void 0 || (_this$emojiButtonRef = _this$emojiButtonRef.deref()) === null || _this$emojiButtonRef === void 0 || _this$emojiButtonRef.focus();
158
165
  });
159
166
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleEmojiClickOutside", function (e) {
160
167
  // Ignore click events for detached elements.
@@ -172,22 +179,22 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
172
179
  }
173
180
  switch (buttonName) {
174
181
  case 'emoji':
175
- _this.emojiButtonRef = ref;
182
+ _this.emojiButtonRef = new WeakRef(ref);
176
183
  break;
177
184
  case 'media':
178
- _this.mediaButtonRef = ref;
185
+ _this.mediaButtonRef = new WeakRef(ref);
179
186
  break;
180
187
  }
181
188
  };
182
189
  });
183
190
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handlePlusButtonRef", function (ref) {
184
191
  if (ref) {
185
- _this.plusButtonRef = ref;
192
+ _this.plusButtonRef = new WeakRef(ref);
186
193
  }
187
194
  });
188
195
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleDropDownButtonRef", function (ref) {
189
196
  if (ref) {
190
- _this.dropdownButtonRef = ref;
197
+ _this.dropdownButtonRef = new WeakRef(ref);
191
198
  }
192
199
  });
193
200
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "toggleTableSelector", function () {
@@ -365,10 +372,11 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
365
372
  onShowMediaPicker = _this$props5.onShowMediaPicker,
366
373
  dispatchAnalyticsEvent = _this$props5.dispatchAnalyticsEvent;
367
374
  if (onShowMediaPicker) {
368
- var _this$props$popupsMou;
369
- var args = _this.mediaButtonRef ? {
370
- ref: _this.mediaButtonRef,
371
- mountPoint: (_this$props$popupsMou = _this.props.popupsMountPoint) !== null && _this$props$popupsMou !== void 0 ? _this$props$popupsMou : _this.mediaButtonRef
375
+ var _this$mediaButtonRef, _this$props$popupsMou;
376
+ var ref = (_this$mediaButtonRef = _this.mediaButtonRef) === null || _this$mediaButtonRef === void 0 ? void 0 : _this$mediaButtonRef.deref();
377
+ var args = ref ? {
378
+ ref: ref,
379
+ mountPoint: (_this$props$popupsMou = _this.props.popupsMountPoint) !== null && _this$props$popupsMou !== void 0 ? _this$props$popupsMou : ref
372
380
  } : undefined;
373
381
  onShowMediaPicker(args);
374
382
  if (dispatchAnalyticsEvent) {
@@ -555,7 +563,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
555
563
  bubbles: true,
556
564
  key: 'ArrowDown'
557
565
  });
558
- (_this$dropdownButtonR = this.dropdownButtonRef) === null || _this$dropdownButtonR === void 0 || _this$dropdownButtonR.dispatchEvent(downArrowEvent);
566
+ (_this$dropdownButtonR = this.dropdownButtonRef) === null || _this$dropdownButtonR === void 0 || (_this$dropdownButtonR = _this$dropdownButtonR.deref()) === null || _this$dropdownButtonR === void 0 || _this$dropdownButtonR.dispatchEvent(downArrowEvent);
559
567
  this.setState(_objectSpread(_objectSpread({}, this.state), {}, {
560
568
  isOpenedByKeyboard: false
561
569
  }));
@@ -598,7 +606,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
598
606
  });
599
607
  };
600
608
  return (0, _react2.jsx)(_ui.Popup, {
601
- target: ref,
609
+ target: ref.deref(),
602
610
  fitHeight: 350,
603
611
  fitWidth: 350,
604
612
  offset: [0, 3],
@@ -671,6 +679,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
671
679
  _tableSelectorButton5,
672
680
  _tableSelectorButton6,
673
681
  _this$props$isDisable,
682
+ _this$plusButtonRef,
674
683
  _this$props$pluginInj3;
675
684
  var _this$state2 = this.state,
676
685
  buttons = _this$state2.buttons,
@@ -788,7 +797,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
788
797
  spacing: this.props.isReducedSpacing ? 'none' : 'default',
789
798
  label: this.props.intl.formatMessage(_messages.messages.insertMenu),
790
799
  open: (0, _experiments.editorExperiment)('insert-menu-in-right-rail', true) ? !isFullPageAppearance && this.state.isPlusMenuOpen : this.state.isPlusMenuOpen,
791
- plusButtonRef: this.plusButtonRef,
800
+ plusButtonRef: (_this$plusButtonRef = this.plusButtonRef) === null || _this$plusButtonRef === void 0 ? void 0 : _this$plusButtonRef.deref(),
792
801
  items: this.state.dropdownItems,
793
802
  onRef: this.handleDropDownButtonRef,
794
803
  onPlusButtonRef: this.handlePlusButtonRef,
@@ -8,6 +8,7 @@ var _react = require("react");
8
8
  var _react2 = require("@emotion/react");
9
9
  var _reactIntlNext = require("react-intl-next");
10
10
  var _messages = require("@atlaskit/editor-common/messages");
11
+ var _uiReact = require("@atlaskit/editor-common/ui-react");
11
12
  var _primitives = require("@atlaskit/primitives");
12
13
  var _colors = require("@atlaskit/theme/colors");
13
14
  /**
@@ -115,7 +116,10 @@ var TableSelectorPopup = function TableSelectorPopup(_ref3) {
115
116
  var buttons = (0, _react.useMemo)(function () {
116
117
  return createArray(maxCols, maxRows);
117
118
  }, [maxCols, maxRows]);
118
- return (0, _react2.jsx)(_primitives.Stack, null, (0, _react2.jsx)("div", {
119
+ var setOutsideClickTargetRef = (0, _react.useContext)(_uiReact.OutsideClickTargetRefContext);
120
+ return (0, _react2.jsx)(_primitives.Stack, {
121
+ ref: setOutsideClickTargetRef
122
+ }, (0, _react2.jsx)("div", {
119
123
  "aria-label": "".concat(formatMessage(_messages.toolbarInsertBlockMessages.tableSizeSelectorPopup)),
120
124
  css:
121
125
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
@@ -4,14 +4,14 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  * @jsx jsx
5
5
  */
6
6
 
7
- import { useCallback, useState } from 'react';
7
+ import { useCallback, useContext, useState } from 'react';
8
8
 
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
10
10
  import { css, jsx } from '@emotion/react';
11
11
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
12
12
  import { ELEMENT_ITEM_HEIGHT, ElementBrowser } from '@atlaskit/editor-common/element-browser';
13
13
  import { IconCode, IconDate, IconDecision, IconDivider, IconExpand, IconPanel, IconQuote, IconStatus } from '@atlaskit/editor-common/quick-insert';
14
- import { withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
14
+ import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
15
15
  // AFP-2532 TODO: Fix automatic suppressions below
16
16
  // eslint-disable-next-line @atlassian/tangerine/import/entry-points
17
17
  import { borderRadius } from '@atlaskit/theme';
@@ -217,11 +217,13 @@ const flexWrapperStyles = css({
217
217
  overflow: 'hidden'
218
218
  });
219
219
  const FlexWrapper = props => {
220
+ const setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
220
221
  const {
221
222
  children,
222
223
  ...divProps
223
224
  } = props;
224
225
  return jsx("div", _extends({
226
+ ref: setOutsideClickTargetRef,
225
227
  css: flexWrapperStyles
226
228
  }, divProps), children);
227
229
  };
@@ -1,4 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _extends from "@babel/runtime/helpers/extends";
2
3
  /**
3
4
  * @jsxRuntime classic
4
5
  * @jsx jsx
@@ -12,7 +13,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
12
13
  import { buttonGroupStyle, separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
13
14
  import { Popup } from '@atlaskit/editor-common/ui';
14
15
  import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
15
- import { withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
16
+ import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
16
17
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
17
18
  import { EmojiPicker as AkEmojiPicker } from '@atlaskit/emoji/picker';
18
19
  import * as colors from '@atlaskit/theme/colors';
@@ -26,7 +27,6 @@ import TableSelectorPopup from './table-selector-popup-with-listeners';
26
27
  * Checks if an element is detached (i.e. not in the current document)
27
28
  */
28
29
  const isDetachedElement = el => !document.body.contains(el);
29
- const EmojiPickerWithListeners = withOuterListeners(AkEmojiPicker);
30
30
  const TABLE_SELECTOR_STRING = 'table selector';
31
31
 
32
32
  // TODO: Jenga team will create a component for a split button using this css
@@ -37,6 +37,13 @@ const getHoverStyles = selector => `&:hover ${selector} {
37
37
  background: ${`var(--ds-background-neutral-hovered, ${colors.N30A})`};
38
38
  }
39
39
  }`;
40
+ const EmojiPicker = props => {
41
+ const setOutsideClickTargetRef = React.useContext(OutsideClickTargetRefContext);
42
+ return jsx(AkEmojiPicker, _extends({
43
+ onPickerRef: setOutsideClickTargetRef
44
+ }, props));
45
+ };
46
+ const EmojiPickerWithListeners = withOuterListeners(EmojiPicker);
40
47
  export const tableButtonWrapper = ({
41
48
  isTableSelectorOpen,
42
49
  isButtonDisabled
@@ -126,8 +133,8 @@ export class ToolbarInsertBlock extends React.PureComponent {
126
133
  isPlusMenuOpen: !isPlusMenuOpen
127
134
  });
128
135
  if ((event === null || event === void 0 ? void 0 : event.key) === 'Escape') {
129
- var _ref;
130
- (_ref = this.plusButtonRef || this.dropdownButtonRef) === null || _ref === void 0 ? void 0 : _ref.focus();
136
+ var _ref, _ref$deref;
137
+ (_ref = this.plusButtonRef || this.dropdownButtonRef) === null || _ref === void 0 ? void 0 : (_ref$deref = _ref.deref()) === null || _ref$deref === void 0 ? void 0 : _ref$deref.focus();
131
138
  }
132
139
  });
133
140
  _defineProperty(this, "toggleEmojiPicker", (inputMethod = INPUT_METHOD.TOOLBAR) => {
@@ -153,9 +160,9 @@ export class ToolbarInsertBlock extends React.PureComponent {
153
160
  });
154
161
  });
155
162
  _defineProperty(this, "handleEmojiPressEscape", () => {
156
- var _this$emojiButtonRef;
163
+ var _this$emojiButtonRef, _this$emojiButtonRef$;
157
164
  this.toggleEmojiPicker(INPUT_METHOD.KEYBOARD);
158
- (_this$emojiButtonRef = this.emojiButtonRef) === null || _this$emojiButtonRef === void 0 ? void 0 : _this$emojiButtonRef.focus();
165
+ (_this$emojiButtonRef = this.emojiButtonRef) === null || _this$emojiButtonRef === void 0 ? void 0 : (_this$emojiButtonRef$ = _this$emojiButtonRef.deref()) === null || _this$emojiButtonRef$ === void 0 ? void 0 : _this$emojiButtonRef$.focus();
159
166
  });
160
167
  _defineProperty(this, "handleEmojiClickOutside", e => {
161
168
  // Ignore click events for detached elements.
@@ -172,21 +179,21 @@ export class ToolbarInsertBlock extends React.PureComponent {
172
179
  }
173
180
  switch (buttonName) {
174
181
  case 'emoji':
175
- this.emojiButtonRef = ref;
182
+ this.emojiButtonRef = new WeakRef(ref);
176
183
  break;
177
184
  case 'media':
178
- this.mediaButtonRef = ref;
185
+ this.mediaButtonRef = new WeakRef(ref);
179
186
  break;
180
187
  }
181
188
  });
182
189
  _defineProperty(this, "handlePlusButtonRef", ref => {
183
190
  if (ref) {
184
- this.plusButtonRef = ref;
191
+ this.plusButtonRef = new WeakRef(ref);
185
192
  }
186
193
  });
187
194
  _defineProperty(this, "handleDropDownButtonRef", ref => {
188
195
  if (ref) {
189
- this.dropdownButtonRef = ref;
196
+ this.dropdownButtonRef = new WeakRef(ref);
190
197
  }
191
198
  });
192
199
  _defineProperty(this, "toggleTableSelector", (inputMethod = INPUT_METHOD.TOOLBAR) => {
@@ -379,10 +386,11 @@ export class ToolbarInsertBlock extends React.PureComponent {
379
386
  dispatchAnalyticsEvent
380
387
  } = this.props;
381
388
  if (onShowMediaPicker) {
382
- var _this$props$popupsMou;
383
- const args = this.mediaButtonRef ? {
384
- ref: this.mediaButtonRef,
385
- mountPoint: (_this$props$popupsMou = this.props.popupsMountPoint) !== null && _this$props$popupsMou !== void 0 ? _this$props$popupsMou : this.mediaButtonRef
389
+ var _this$mediaButtonRef, _this$props$popupsMou;
390
+ const ref = (_this$mediaButtonRef = this.mediaButtonRef) === null || _this$mediaButtonRef === void 0 ? void 0 : _this$mediaButtonRef.deref();
391
+ const args = ref ? {
392
+ ref,
393
+ mountPoint: (_this$props$popupsMou = this.props.popupsMountPoint) !== null && _this$props$popupsMou !== void 0 ? _this$props$popupsMou : ref
386
394
  } : undefined;
387
395
  onShowMediaPicker(args);
388
396
  if (dispatchAnalyticsEvent) {
@@ -607,12 +615,12 @@ export class ToolbarInsertBlock extends React.PureComponent {
607
615
  });
608
616
  }
609
617
  if (this.state.isOpenedByKeyboard) {
610
- var _this$dropdownButtonR;
618
+ var _this$dropdownButtonR, _this$dropdownButtonR2;
611
619
  const downArrowEvent = new KeyboardEvent('keydown', {
612
620
  bubbles: true,
613
621
  key: 'ArrowDown'
614
622
  });
615
- (_this$dropdownButtonR = this.dropdownButtonRef) === null || _this$dropdownButtonR === void 0 ? void 0 : _this$dropdownButtonR.dispatchEvent(downArrowEvent);
623
+ (_this$dropdownButtonR = this.dropdownButtonRef) === null || _this$dropdownButtonR === void 0 ? void 0 : (_this$dropdownButtonR2 = _this$dropdownButtonR.deref()) === null || _this$dropdownButtonR2 === void 0 ? void 0 : _this$dropdownButtonR2.dispatchEvent(downArrowEvent);
616
624
  this.setState({
617
625
  ...this.state,
618
626
  isOpenedByKeyboard: false
@@ -658,7 +666,7 @@ export class ToolbarInsertBlock extends React.PureComponent {
658
666
  });
659
667
  };
660
668
  return jsx(Popup, {
661
- target: ref,
669
+ target: ref.deref(),
662
670
  fitHeight: 350,
663
671
  fitWidth: 350,
664
672
  offset: [0, 3],
@@ -714,7 +722,7 @@ export class ToolbarInsertBlock extends React.PureComponent {
714
722
  });
715
723
  }
716
724
  render() {
717
- var _tableButton, _tableButton2, _tableButton3, _tableButton4, _tableButton5, _tableButton6, _tableButton7, _tableSelectorButton, _tableSelectorButton2, _tableSelectorButton3, _tableSelectorButton4, _tableSelectorButton5, _tableSelectorButton6, _this$props$isDisable, _this$props$pluginInj7;
725
+ var _tableButton, _tableButton2, _tableButton3, _tableButton4, _tableButton5, _tableButton6, _tableButton7, _tableSelectorButton, _tableSelectorButton2, _tableSelectorButton3, _tableSelectorButton4, _tableSelectorButton5, _tableSelectorButton6, _this$props$isDisable, _this$plusButtonRef, _this$props$pluginInj7;
718
726
  const {
719
727
  buttons,
720
728
  dropdownItems,
@@ -822,7 +830,7 @@ export class ToolbarInsertBlock extends React.PureComponent {
822
830
  spacing: this.props.isReducedSpacing ? 'none' : 'default',
823
831
  label: this.props.intl.formatMessage(messages.insertMenu),
824
832
  open: editorExperiment('insert-menu-in-right-rail', true) ? !isFullPageAppearance && this.state.isPlusMenuOpen : this.state.isPlusMenuOpen,
825
- plusButtonRef: this.plusButtonRef,
833
+ plusButtonRef: (_this$plusButtonRef = this.plusButtonRef) === null || _this$plusButtonRef === void 0 ? void 0 : _this$plusButtonRef.deref(),
826
834
  items: this.state.dropdownItems,
827
835
  onRef: this.handleDropDownButtonRef,
828
836
  onPlusButtonRef: this.handlePlusButtonRef,
@@ -2,11 +2,12 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import { useEffect, useMemo, useRef } from 'react';
5
+ import { useContext, useEffect, useMemo, useRef } from 'react';
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
7
  import { css, jsx } from '@emotion/react';
8
8
  import { injectIntl } from 'react-intl-next';
9
9
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
10
+ import { OutsideClickTargetRefContext } from '@atlaskit/editor-common/ui-react';
10
11
  import { Stack } from '@atlaskit/primitives';
11
12
  import { B100 } from '@atlaskit/theme/colors';
12
13
  export const TABLE_SELECTOR_BUTTON_GAP = 2;
@@ -106,7 +107,10 @@ const TableSelectorPopup = ({
106
107
  const buttons = useMemo(() => {
107
108
  return createArray(maxCols, maxRows);
108
109
  }, [maxCols, maxRows]);
109
- return jsx(Stack, null, jsx("div", {
110
+ const setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
111
+ return jsx(Stack, {
112
+ ref: setOutsideClickTargetRef
113
+ }, jsx("div", {
110
114
  "aria-label": `${formatMessage(messages.tableSizeSelectorPopup)}`,
111
115
  css:
112
116
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
@@ -8,14 +8,14 @@ var _excluded = ["children"];
8
8
  * @jsx jsx
9
9
  */
10
10
 
11
- import { useCallback, useState } from 'react';
11
+ import { useCallback, useContext, useState } from 'react';
12
12
 
13
13
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
14
14
  import { css, jsx } from '@emotion/react';
15
15
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
16
16
  import { ELEMENT_ITEM_HEIGHT, ElementBrowser } from '@atlaskit/editor-common/element-browser';
17
17
  import { IconCode, IconDate, IconDecision, IconDivider, IconExpand, IconPanel, IconQuote, IconStatus } from '@atlaskit/editor-common/quick-insert';
18
- import { withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
18
+ import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
19
19
  // AFP-2532 TODO: Fix automatic suppressions below
20
20
  // eslint-disable-next-line @atlassian/tangerine/import/entry-points
21
21
  import { borderRadius } from '@atlaskit/theme';
@@ -225,9 +225,11 @@ var flexWrapperStyles = css({
225
225
  overflow: 'hidden'
226
226
  });
227
227
  var FlexWrapper = function FlexWrapper(props) {
228
+ var setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
228
229
  var children = props.children,
229
230
  divProps = _objectWithoutProperties(props, _excluded);
230
231
  return jsx("div", _extends({
232
+ ref: setOutsideClickTargetRef,
231
233
  css: flexWrapperStyles
232
234
  }, divProps), children);
233
235
  };
@@ -7,6 +7,7 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
9
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
10
+ import _extends from "@babel/runtime/helpers/extends";
10
11
  var _templateObject;
11
12
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
12
13
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -28,7 +29,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
28
29
  import { buttonGroupStyle, separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
29
30
  import { Popup } from '@atlaskit/editor-common/ui';
30
31
  import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
31
- import { withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
32
+ import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
32
33
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
33
34
  import { EmojiPicker as AkEmojiPicker } from '@atlaskit/emoji/picker';
34
35
  import * as colors from '@atlaskit/theme/colors';
@@ -44,13 +45,19 @@ import TableSelectorPopup from './table-selector-popup-with-listeners';
44
45
  var isDetachedElement = function isDetachedElement(el) {
45
46
  return !document.body.contains(el);
46
47
  };
47
- var EmojiPickerWithListeners = withOuterListeners(AkEmojiPicker);
48
48
  var TABLE_SELECTOR_STRING = 'table selector';
49
49
 
50
50
  // TODO: Jenga team will create a component for a split button using this css
51
51
  var getHoverStyles = function getHoverStyles(selector) {
52
52
  return "&:hover ".concat(selector, " {\n background: ", "var(--ds-background-neutral-subtle-hovered, ".concat(colors.N20A, ")"), ";\n\n &:hover {\n background: ", "var(--ds-background-neutral-hovered, ".concat(colors.N30A, ")"), ";\n }\n }");
53
53
  };
54
+ var EmojiPicker = function EmojiPicker(props) {
55
+ var setOutsideClickTargetRef = React.useContext(OutsideClickTargetRefContext);
56
+ return jsx(AkEmojiPicker, _extends({
57
+ onPickerRef: setOutsideClickTargetRef
58
+ }, props));
59
+ };
60
+ var EmojiPickerWithListeners = withOuterListeners(EmojiPicker);
54
61
  export var tableButtonWrapper = function tableButtonWrapper(_ref) {
55
62
  var isTableSelectorOpen = _ref.isTableSelectorOpen,
56
63
  isButtonDisabled = _ref.isButtonDisabled;
@@ -116,7 +123,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
116
123
  });
117
124
  if ((event === null || event === void 0 ? void 0 : event.key) === 'Escape') {
118
125
  var _ref2;
119
- (_ref2 = _this.plusButtonRef || _this.dropdownButtonRef) === null || _ref2 === void 0 || _ref2.focus();
126
+ (_ref2 = _this.plusButtonRef || _this.dropdownButtonRef) === null || _ref2 === void 0 || (_ref2 = _ref2.deref()) === null || _ref2 === void 0 || _ref2.focus();
120
127
  }
121
128
  });
122
129
  _defineProperty(_assertThisInitialized(_this), "toggleEmojiPicker", function () {
@@ -145,7 +152,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
145
152
  _defineProperty(_assertThisInitialized(_this), "handleEmojiPressEscape", function () {
146
153
  var _this$emojiButtonRef;
147
154
  _this.toggleEmojiPicker(INPUT_METHOD.KEYBOARD);
148
- (_this$emojiButtonRef = _this.emojiButtonRef) === null || _this$emojiButtonRef === void 0 || _this$emojiButtonRef.focus();
155
+ (_this$emojiButtonRef = _this.emojiButtonRef) === null || _this$emojiButtonRef === void 0 || (_this$emojiButtonRef = _this$emojiButtonRef.deref()) === null || _this$emojiButtonRef === void 0 || _this$emojiButtonRef.focus();
149
156
  });
150
157
  _defineProperty(_assertThisInitialized(_this), "handleEmojiClickOutside", function (e) {
151
158
  // Ignore click events for detached elements.
@@ -163,22 +170,22 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
163
170
  }
164
171
  switch (buttonName) {
165
172
  case 'emoji':
166
- _this.emojiButtonRef = ref;
173
+ _this.emojiButtonRef = new WeakRef(ref);
167
174
  break;
168
175
  case 'media':
169
- _this.mediaButtonRef = ref;
176
+ _this.mediaButtonRef = new WeakRef(ref);
170
177
  break;
171
178
  }
172
179
  };
173
180
  });
174
181
  _defineProperty(_assertThisInitialized(_this), "handlePlusButtonRef", function (ref) {
175
182
  if (ref) {
176
- _this.plusButtonRef = ref;
183
+ _this.plusButtonRef = new WeakRef(ref);
177
184
  }
178
185
  });
179
186
  _defineProperty(_assertThisInitialized(_this), "handleDropDownButtonRef", function (ref) {
180
187
  if (ref) {
181
- _this.dropdownButtonRef = ref;
188
+ _this.dropdownButtonRef = new WeakRef(ref);
182
189
  }
183
190
  });
184
191
  _defineProperty(_assertThisInitialized(_this), "toggleTableSelector", function () {
@@ -356,10 +363,11 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
356
363
  onShowMediaPicker = _this$props5.onShowMediaPicker,
357
364
  dispatchAnalyticsEvent = _this$props5.dispatchAnalyticsEvent;
358
365
  if (onShowMediaPicker) {
359
- var _this$props$popupsMou;
360
- var args = _this.mediaButtonRef ? {
361
- ref: _this.mediaButtonRef,
362
- mountPoint: (_this$props$popupsMou = _this.props.popupsMountPoint) !== null && _this$props$popupsMou !== void 0 ? _this$props$popupsMou : _this.mediaButtonRef
366
+ var _this$mediaButtonRef, _this$props$popupsMou;
367
+ var ref = (_this$mediaButtonRef = _this.mediaButtonRef) === null || _this$mediaButtonRef === void 0 ? void 0 : _this$mediaButtonRef.deref();
368
+ var args = ref ? {
369
+ ref: ref,
370
+ mountPoint: (_this$props$popupsMou = _this.props.popupsMountPoint) !== null && _this$props$popupsMou !== void 0 ? _this$props$popupsMou : ref
363
371
  } : undefined;
364
372
  onShowMediaPicker(args);
365
373
  if (dispatchAnalyticsEvent) {
@@ -546,7 +554,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
546
554
  bubbles: true,
547
555
  key: 'ArrowDown'
548
556
  });
549
- (_this$dropdownButtonR = this.dropdownButtonRef) === null || _this$dropdownButtonR === void 0 || _this$dropdownButtonR.dispatchEvent(downArrowEvent);
557
+ (_this$dropdownButtonR = this.dropdownButtonRef) === null || _this$dropdownButtonR === void 0 || (_this$dropdownButtonR = _this$dropdownButtonR.deref()) === null || _this$dropdownButtonR === void 0 || _this$dropdownButtonR.dispatchEvent(downArrowEvent);
550
558
  this.setState(_objectSpread(_objectSpread({}, this.state), {}, {
551
559
  isOpenedByKeyboard: false
552
560
  }));
@@ -589,7 +597,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
589
597
  });
590
598
  };
591
599
  return jsx(Popup, {
592
- target: ref,
600
+ target: ref.deref(),
593
601
  fitHeight: 350,
594
602
  fitWidth: 350,
595
603
  offset: [0, 3],
@@ -662,6 +670,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
662
670
  _tableSelectorButton5,
663
671
  _tableSelectorButton6,
664
672
  _this$props$isDisable,
673
+ _this$plusButtonRef,
665
674
  _this$props$pluginInj3;
666
675
  var _this$state2 = this.state,
667
676
  buttons = _this$state2.buttons,
@@ -779,7 +788,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
779
788
  spacing: this.props.isReducedSpacing ? 'none' : 'default',
780
789
  label: this.props.intl.formatMessage(messages.insertMenu),
781
790
  open: editorExperiment('insert-menu-in-right-rail', true) ? !isFullPageAppearance && this.state.isPlusMenuOpen : this.state.isPlusMenuOpen,
782
- plusButtonRef: this.plusButtonRef,
791
+ plusButtonRef: (_this$plusButtonRef = this.plusButtonRef) === null || _this$plusButtonRef === void 0 ? void 0 : _this$plusButtonRef.deref(),
783
792
  items: this.state.dropdownItems,
784
793
  onRef: this.handleDropDownButtonRef,
785
794
  onPlusButtonRef: this.handlePlusButtonRef,
@@ -2,11 +2,12 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import { useEffect, useMemo, useRef } from 'react';
5
+ import { useContext, useEffect, useMemo, useRef } from 'react';
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
7
  import { css, jsx } from '@emotion/react';
8
8
  import { injectIntl } from 'react-intl-next';
9
9
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
10
+ import { OutsideClickTargetRefContext } from '@atlaskit/editor-common/ui-react';
10
11
  import { Stack } from '@atlaskit/primitives';
11
12
  import { B100 } from '@atlaskit/theme/colors';
12
13
  export var TABLE_SELECTOR_BUTTON_GAP = 2;
@@ -107,7 +108,10 @@ var TableSelectorPopup = function TableSelectorPopup(_ref3) {
107
108
  var buttons = useMemo(function () {
108
109
  return createArray(maxCols, maxRows);
109
110
  }, [maxCols, maxRows]);
110
- return jsx(Stack, null, jsx("div", {
111
+ var setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
112
+ return jsx(Stack, {
113
+ ref: setOutsideClickTargetRef
114
+ }, jsx("div", {
111
115
  "aria-label": "".concat(formatMessage(messages.tableSizeSelectorPopup)),
112
116
  css:
113
117
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-insert-block",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
4
4
  "description": "Insert block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/button": "^20.3.0",
35
- "@atlaskit/editor-common": "^94.2.0",
35
+ "@atlaskit/editor-common": "^94.5.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
37
37
  "@atlaskit/editor-plugin-block-type": "^3.16.0",
38
38
  "@atlaskit/editor-plugin-code-block": "^3.5.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/editor-plugin-hyperlink": "^3.1.0",
45
45
  "@atlaskit/editor-plugin-image-upload": "^1.2.0",
46
46
  "@atlaskit/editor-plugin-layout": "^1.9.0",
47
- "@atlaskit/editor-plugin-media": "^1.37.0",
47
+ "@atlaskit/editor-plugin-media": "^1.38.0",
48
48
  "@atlaskit/editor-plugin-media-insert": "^3.2.0",
49
49
  "@atlaskit/editor-plugin-mentions": "^2.10.0",
50
50
  "@atlaskit/editor-plugin-panel": "^2.6.0",
@@ -57,7 +57,7 @@
57
57
  "@atlaskit/editor-plugin-tasks-and-decisions": "^2.11.0",
58
58
  "@atlaskit/editor-plugin-type-ahead": "^1.10.0",
59
59
  "@atlaskit/editor-prosemirror": "6.0.0",
60
- "@atlaskit/editor-shared-styles": "^3.0.0",
60
+ "@atlaskit/editor-shared-styles": "^3.1.0",
61
61
  "@atlaskit/emoji": "^67.8.0",
62
62
  "@atlaskit/heading": "2.4.6",
63
63
  "@atlaskit/icon": "^22.24.0",
@@ -65,7 +65,7 @@
65
65
  "@atlaskit/platform-feature-flags": "^0.3.0",
66
66
  "@atlaskit/primitives": "^12.2.0",
67
67
  "@atlaskit/theme": "^14.0.0",
68
- "@atlaskit/tmp-editor-statsig": "^2.8.0",
68
+ "@atlaskit/tmp-editor-statsig": "^2.10.0",
69
69
  "@atlaskit/tokens": "^2.0.0",
70
70
  "@atlaskit/tooltip": "18.8.5",
71
71
  "@babel/runtime": "^7.0.0",