@atlaskit/editor-plugin-find-replace 2.0.3 → 2.0.5

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 (26) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/findReplacePlugin.js +30 -4
  3. package/dist/cjs/pm-plugins/plugin-factory.js +1 -1
  4. package/dist/cjs/pm-plugins/utils/index.js +0 -1
  5. package/dist/cjs/ui/{FindReplaceToolbarButtonWithState.js → FindReplaceDropDownOrToolbarButtonWithState.js} +5 -2
  6. package/dist/cjs/ui/FindReplaceDropdown.js +68 -0
  7. package/dist/cjs/ui/styles.js +0 -2
  8. package/dist/es2019/findReplacePlugin.js +31 -4
  9. package/dist/es2019/pm-plugins/plugin-factory.js +1 -1
  10. package/dist/es2019/pm-plugins/utils/index.js +0 -1
  11. package/dist/es2019/ui/{FindReplaceToolbarButtonWithState.js → FindReplaceDropDownOrToolbarButtonWithState.js} +5 -2
  12. package/dist/es2019/ui/FindReplaceDropdown.js +63 -0
  13. package/dist/es2019/ui/styles.js +0 -1
  14. package/dist/esm/findReplacePlugin.js +30 -4
  15. package/dist/esm/pm-plugins/plugin-factory.js +1 -1
  16. package/dist/esm/pm-plugins/utils/index.js +0 -1
  17. package/dist/esm/ui/{FindReplaceToolbarButtonWithState.js → FindReplaceDropDownOrToolbarButtonWithState.js} +5 -2
  18. package/dist/esm/ui/FindReplaceDropdown.js +61 -0
  19. package/dist/esm/ui/styles.js +0 -1
  20. package/dist/types/types/index.d.ts +1 -0
  21. package/dist/{types-ts4.5/ui/FindReplaceToolbarButtonWithState.d.ts → types/ui/FindReplaceDropDownOrToolbarButtonWithState.d.ts} +1 -1
  22. package/dist/types/ui/FindReplaceDropdown.d.ts +15 -0
  23. package/dist/types-ts4.5/types/index.d.ts +1 -0
  24. package/dist/{types/ui/FindReplaceToolbarButtonWithState.d.ts → types-ts4.5/ui/FindReplaceDropDownOrToolbarButtonWithState.d.ts} +1 -1
  25. package/dist/types-ts4.5/ui/FindReplaceDropdown.d.ts +15 -0
  26. package/package.json +8 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-find-replace
2
2
 
3
+ ## 2.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#130689](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/130689)
8
+ [`d8c4b9bdc0075`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d8c4b9bdc0075) -
9
+ Fixed mount point for find and replace popup
10
+ - Updated dependencies
11
+
12
+ ## 2.0.4
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 2.0.3
4
19
 
5
20
  ### Patch Changes
@@ -8,10 +8,11 @@ exports.findReplacePlugin = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _types = require("@atlaskit/editor-common/types");
10
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
11
12
  var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
12
13
  var _main = require("./pm-plugins/main");
13
14
  var _pluginKey = require("./pm-plugins/plugin-key");
14
- var _FindReplaceToolbarButtonWithState = _interopRequireDefault(require("./ui/FindReplaceToolbarButtonWithState"));
15
+ var _FindReplaceDropDownOrToolbarButtonWithState = _interopRequireDefault(require("./ui/FindReplaceDropDownOrToolbarButtonWithState"));
15
16
  var findReplacePlugin = exports.findReplacePlugin = function findReplacePlugin(_ref) {
16
17
  var _api$primaryToolbar;
17
18
  var props = _ref.config,
@@ -29,7 +30,7 @@ var findReplacePlugin = exports.findReplacePlugin = function findReplacePlugin(_
29
30
  if (props !== null && props !== void 0 && props.twoLineEditorToolbar) {
30
31
  return null;
31
32
  } else {
32
- return /*#__PURE__*/_react.default.createElement(_FindReplaceToolbarButtonWithState.default, {
33
+ return /*#__PURE__*/_react.default.createElement(_FindReplaceDropDownOrToolbarButtonWithState.default, {
33
34
  popupsBoundariesElement: popupsBoundariesElement,
34
35
  popupsMountPoint: popupsMountPoint,
35
36
  popupsScrollableElement: popupsScrollableElement,
@@ -79,7 +80,7 @@ var findReplacePlugin = exports.findReplacePlugin = function findReplacePlugin(_
79
80
  containerElement = _ref4.containerElement,
80
81
  dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent,
81
82
  isToolbarReducedSpacing = _ref4.isToolbarReducedSpacing;
82
- return /*#__PURE__*/_react.default.createElement(_FindReplaceToolbarButtonWithState.default, {
83
+ return /*#__PURE__*/_react.default.createElement(_FindReplaceDropDownOrToolbarButtonWithState.default, {
83
84
  popupsBoundariesElement: popupsBoundariesElement,
84
85
  popupsMountPoint: popupsMountPoint,
85
86
  popupsScrollableElement: popupsScrollableElement,
@@ -91,6 +92,31 @@ var findReplacePlugin = exports.findReplacePlugin = function findReplacePlugin(_
91
92
  });
92
93
  }
93
94
  },
94
- primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
95
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
96
+ contentComponent: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1', {
97
+ exposure: true
98
+ }) ? function (_ref5) {
99
+ var editorView = _ref5.editorView,
100
+ containerElement = _ref5.containerElement,
101
+ popupsMountPoint = _ref5.popupsMountPoint,
102
+ popupsBoundariesElement = _ref5.popupsBoundariesElement,
103
+ popupsScrollableElement = _ref5.popupsScrollableElement,
104
+ wrapperElement = _ref5.wrapperElement,
105
+ dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
106
+ var popupsMountPointEl = popupsMountPoint || ( // eslint-disable-next-line @atlaskit/editor/no-as-casting
107
+ wrapperElement === null || wrapperElement === void 0 ? void 0 : wrapperElement.querySelector("[data-editor-container='true']"));
108
+ return /*#__PURE__*/_react.default.createElement(_FindReplaceDropDownOrToolbarButtonWithState.default, {
109
+ popupsBoundariesElement: popupsBoundariesElement,
110
+ popupsMountPoint: popupsMountPointEl,
111
+ popupsScrollableElement: popupsScrollableElement || containerElement || undefined,
112
+ isToolbarReducedSpacing: false,
113
+ editorView: editorView,
114
+ containerElement: containerElement,
115
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
116
+ takeFullWidth: props === null || props === void 0 ? void 0 : props.takeFullWidth,
117
+ api: api,
118
+ doesNotHaveButton: true
119
+ });
120
+ } : undefined
95
121
  };
96
122
  };
@@ -16,7 +16,7 @@ var _utils2 = require("./utils");
16
16
  var _array = require("./utils/array");
17
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
- // TODO: move into index export
19
+ // TODO: ED-26959 - move into index export
20
20
 
21
21
  var handleDocChanged = function handleDocChanged(tr, pluginState) {
22
22
  var isActive = pluginState.isActive,
@@ -150,7 +150,6 @@ var removeDecorationsFromSet = exports.removeDecorationsFromSet = function remov
150
150
  // there is a bug in prosemirror-view where it can't cope with deleting inline
151
151
  // decorations from a set in some cases (where there are multiple levels of nested
152
152
  // children arrays), and it deletes more decorations than it should
153
- // todo: ticket link
154
153
  var lostDecorations = findLostAdjacentDecorations(decorationsToRemove, prevDecorations, newDecorations);
155
154
  if (lostDecorations.length > 0) {
156
155
  decorationSet = decorationSet.add(doc, lostDecorations);
@@ -11,6 +11,7 @@ var _react = _interopRequireWildcard(require("react"));
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
12
  var _commands = require("../pm-plugins/commands");
13
13
  var _commandsWithAnalytics = require("../pm-plugins/commands-with-analytics");
14
+ var _FindReplaceDropdown = _interopRequireDefault(require("./FindReplaceDropdown"));
14
15
  var _FindReplaceToolbarButton = _interopRequireDefault(require("./FindReplaceToolbarButton"));
15
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -50,7 +51,8 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
50
51
  dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
51
52
  takeFullWidth = _ref2.takeFullWidth,
52
53
  api = _ref2.api,
53
- isButtonHidden = _ref2.isButtonHidden;
54
+ isButtonHidden = _ref2.isButtonHidden,
55
+ doesNotHaveButton = _ref2.doesNotHaveButton;
54
56
  var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
55
57
  var _useSharedPluginState = useSharedPluginStateNoDebounce(api),
56
58
  findReplaceState = _useSharedPluginState.findReplaceState;
@@ -138,7 +140,8 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
138
140
  if (!findReplaceState) {
139
141
  return null;
140
142
  }
141
- return /*#__PURE__*/_react.default.createElement(_FindReplaceToolbarButton.default, {
143
+ var DropDownComponent = doesNotHaveButton ? _FindReplaceDropdown.default : _FindReplaceToolbarButton.default;
144
+ return /*#__PURE__*/_react.default.createElement(DropDownComponent, {
142
145
  shouldMatchCase: findReplaceState.shouldMatchCase,
143
146
  onToggleMatchCase: handleToggleMatchCase,
144
147
  isActive: findReplaceState.isActive,
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _reactIntlNext = require("react-intl-next");
11
+ var _analytics = require("@atlaskit/editor-common/analytics");
12
+ var _uiMenu = require("@atlaskit/editor-common/ui-menu");
13
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
14
+ var _primitives = require("@atlaskit/primitives");
15
+ var _FindReplace = _interopRequireDefault(require("./FindReplace"));
16
+ var findReplaceWrapperStyles = (0, _primitives.xcss)({
17
+ display: 'flex',
18
+ flexDirection: 'column'
19
+ });
20
+
21
+ // Magic number taken from ../FindReplaceToolbarButton.tsx
22
+ var dropdownWidthNewDesign = 382;
23
+ var FindReplaceDropdown = function FindReplaceDropdown(props) {
24
+ var findText = props.findText,
25
+ replaceText = props.replaceText,
26
+ isActive = props.isActive,
27
+ index = props.index,
28
+ numMatches = props.numMatches,
29
+ popupsMountPoint = props.popupsMountPoint,
30
+ onCancel = props.onCancel;
31
+ if (!popupsMountPoint) {
32
+ return null;
33
+ }
34
+ return /*#__PURE__*/_react.default.createElement(_uiMenu.Dropdown, {
35
+ target: popupsMountPoint,
36
+ mountTo: popupsMountPoint,
37
+ forcePlacement: true,
38
+ alignX: 'right',
39
+ alignY: 'start',
40
+ offset: [4, 0],
41
+ isOpen: isActive,
42
+ handleEscapeKeydown: function handleEscapeKeydown() {
43
+ if (isActive) {
44
+ onCancel({
45
+ triggerMethod: _analytics.TRIGGER_METHOD.KEYBOARD
46
+ });
47
+ }
48
+ },
49
+ fitWidth: dropdownWidthNewDesign,
50
+ zIndex: _editorSharedStyles.akEditorFloatingPanelZIndex,
51
+ arrowKeyNavigationProviderOptions: {
52
+ type: _uiMenu.ArrowKeyNavigationType.MENU,
53
+ disableArrowKeyNavigation: true
54
+ }
55
+ }, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
56
+ xcss: findReplaceWrapperStyles
57
+ }, /*#__PURE__*/_react.default.createElement(_FindReplace.default, (0, _extends2.default)({
58
+ findText: findText,
59
+ replaceText: replaceText,
60
+ count: {
61
+ index: index,
62
+ total: numMatches
63
+ }
64
+ // Ignored via go/ees005
65
+ // eslint-disable-next-line react/jsx-props-no-spreading
66
+ }, props))));
67
+ };
68
+ var _default = exports.default = (0, _reactIntlNext.injectIntl)(FindReplaceDropdown);
@@ -15,8 +15,6 @@ var _colors = require("@atlaskit/theme/colors");
15
15
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
16
16
  /* eslint-disable */
17
17
 
18
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4290
19
-
20
18
  var searchMatchClass = exports.searchMatchClass = 'search-match';
21
19
  var selectedSearchMatchClass = exports.selectedSearchMatchClass = 'selected-search-match';
22
20
  var findReplaceStyles = exports.findReplaceStyles = (0, _react.css)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, ".".concat(searchMatchClass), {
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import { ToolbarSize } from '@atlaskit/editor-common/types';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
5
  import keymapPlugin from './pm-plugins/keymap';
5
6
  import { createPlugin } from './pm-plugins/main';
6
7
  import { findReplacePluginKey } from './pm-plugins/plugin-key';
7
- import FindReplaceToolbarButtonWithState from './ui/FindReplaceToolbarButtonWithState';
8
+ import FindReplaceDropDownOrToolbarButtonWithState from './ui/FindReplaceDropDownOrToolbarButtonWithState';
8
9
  export const findReplacePlugin = ({
9
10
  config: props,
10
11
  api
@@ -24,7 +25,7 @@ export const findReplacePlugin = ({
24
25
  if (props !== null && props !== void 0 && props.twoLineEditorToolbar) {
25
26
  return null;
26
27
  } else {
27
- return /*#__PURE__*/React.createElement(FindReplaceToolbarButtonWithState, {
28
+ return /*#__PURE__*/React.createElement(FindReplaceDropDownOrToolbarButtonWithState, {
28
29
  popupsBoundariesElement: popupsBoundariesElement,
29
30
  popupsMountPoint: popupsMountPoint,
30
31
  popupsScrollableElement: popupsScrollableElement,
@@ -74,7 +75,7 @@ export const findReplacePlugin = ({
74
75
  dispatchAnalyticsEvent,
75
76
  isToolbarReducedSpacing
76
77
  }) => {
77
- return /*#__PURE__*/React.createElement(FindReplaceToolbarButtonWithState, {
78
+ return /*#__PURE__*/React.createElement(FindReplaceDropDownOrToolbarButtonWithState, {
78
79
  popupsBoundariesElement: popupsBoundariesElement,
79
80
  popupsMountPoint: popupsMountPoint,
80
81
  popupsScrollableElement: popupsScrollableElement,
@@ -86,6 +87,32 @@ export const findReplacePlugin = ({
86
87
  });
87
88
  }
88
89
  },
89
- primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
90
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
91
+ contentComponent: editorExperiment('platform_editor_controls', 'variant1', {
92
+ exposure: true
93
+ }) ? ({
94
+ editorView,
95
+ containerElement,
96
+ popupsMountPoint,
97
+ popupsBoundariesElement,
98
+ popupsScrollableElement,
99
+ wrapperElement,
100
+ dispatchAnalyticsEvent
101
+ }) => {
102
+ const popupsMountPointEl = popupsMountPoint || ( // eslint-disable-next-line @atlaskit/editor/no-as-casting
103
+ wrapperElement === null || wrapperElement === void 0 ? void 0 : wrapperElement.querySelector("[data-editor-container='true']"));
104
+ return /*#__PURE__*/React.createElement(FindReplaceDropDownOrToolbarButtonWithState, {
105
+ popupsBoundariesElement: popupsBoundariesElement,
106
+ popupsMountPoint: popupsMountPointEl,
107
+ popupsScrollableElement: popupsScrollableElement || containerElement || undefined,
108
+ isToolbarReducedSpacing: false,
109
+ editorView: editorView,
110
+ containerElement: containerElement,
111
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
112
+ takeFullWidth: props === null || props === void 0 ? void 0 : props.takeFullWidth,
113
+ api: api,
114
+ doesNotHaveButton: true
115
+ });
116
+ } : undefined
90
117
  };
91
118
  };
@@ -4,7 +4,7 @@ import { initialState } from './main';
4
4
  import { findReplacePluginKey } from './plugin-key';
5
5
  import reducer from './reducer';
6
6
  import { createDecorations, findDecorationFromMatch, findMatches, findSearchIndex, isMatchAffectedByStep, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
7
- import { findUniqueItemsIn } from './utils/array'; // TODO: move into index export
7
+ import { findUniqueItemsIn } from './utils/array'; // TODO: ED-26959 - move into index export
8
8
 
9
9
  const handleDocChanged = (tr, pluginState) => {
10
10
  const {
@@ -123,7 +123,6 @@ export const removeDecorationsFromSet = (decorationSet, decorationsToRemove, doc
123
123
  // there is a bug in prosemirror-view where it can't cope with deleting inline
124
124
  // decorations from a set in some cases (where there are multiple levels of nested
125
125
  // children arrays), and it deletes more decorations than it should
126
- // todo: ticket link
127
126
  const lostDecorations = findLostAdjacentDecorations(decorationsToRemove, prevDecorations, newDecorations);
128
127
  if (lostDecorations.length > 0) {
129
128
  decorationSet = decorationSet.add(doc, lostDecorations);
@@ -2,6 +2,7 @@ import React, { useLayoutEffect, useState } from 'react';
2
2
  import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { blur, toggleMatchCase } from '../pm-plugins/commands';
4
4
  import { activateWithAnalytics, cancelSearchWithAnalytics, findNextWithAnalytics, findPrevWithAnalytics, findWithAnalytics, replaceAllWithAnalytics, replaceWithAnalytics } from '../pm-plugins/commands-with-analytics';
5
+ import FindReplaceDropdown from './FindReplaceDropdown';
5
6
  import FindReplaceToolbarButton from './FindReplaceToolbarButton';
6
7
 
7
8
  // light implementation of useSharedPluginState(). This is due to findreplace
@@ -37,7 +38,8 @@ const FindReplaceToolbarButtonWithState = ({
37
38
  dispatchAnalyticsEvent,
38
39
  takeFullWidth,
39
40
  api,
40
- isButtonHidden
41
+ isButtonHidden,
42
+ doesNotHaveButton
41
43
  }) => {
42
44
  var _api$analytics;
43
45
  const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
@@ -123,7 +125,8 @@ const FindReplaceToolbarButtonWithState = ({
123
125
  if (!findReplaceState) {
124
126
  return null;
125
127
  }
126
- return /*#__PURE__*/React.createElement(FindReplaceToolbarButton, {
128
+ const DropDownComponent = doesNotHaveButton ? FindReplaceDropdown : FindReplaceToolbarButton;
129
+ return /*#__PURE__*/React.createElement(DropDownComponent, {
127
130
  shouldMatchCase: findReplaceState.shouldMatchCase,
128
131
  onToggleMatchCase: handleToggleMatchCase,
129
132
  isActive: findReplaceState.isActive,
@@ -0,0 +1,63 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { injectIntl } from 'react-intl-next';
4
+ import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { ArrowKeyNavigationType, Dropdown } from '@atlaskit/editor-common/ui-menu';
6
+ import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
7
+ import { Box, xcss } from '@atlaskit/primitives';
8
+ import FindReplace from './FindReplace';
9
+ const findReplaceWrapperStyles = xcss({
10
+ display: 'flex',
11
+ flexDirection: 'column'
12
+ });
13
+
14
+ // Magic number taken from ../FindReplaceToolbarButton.tsx
15
+ const dropdownWidthNewDesign = 382;
16
+ const FindReplaceDropdown = props => {
17
+ const {
18
+ findText,
19
+ replaceText,
20
+ isActive,
21
+ index,
22
+ numMatches,
23
+ popupsMountPoint,
24
+ onCancel
25
+ } = props;
26
+ if (!popupsMountPoint) {
27
+ return null;
28
+ }
29
+ return /*#__PURE__*/React.createElement(Dropdown, {
30
+ target: popupsMountPoint,
31
+ mountTo: popupsMountPoint,
32
+ forcePlacement: true,
33
+ alignX: 'right',
34
+ alignY: 'start',
35
+ offset: [4, 0],
36
+ isOpen: isActive,
37
+ handleEscapeKeydown: () => {
38
+ if (isActive) {
39
+ onCancel({
40
+ triggerMethod: TRIGGER_METHOD.KEYBOARD
41
+ });
42
+ }
43
+ },
44
+ fitWidth: dropdownWidthNewDesign,
45
+ zIndex: akEditorFloatingPanelZIndex,
46
+ arrowKeyNavigationProviderOptions: {
47
+ type: ArrowKeyNavigationType.MENU,
48
+ disableArrowKeyNavigation: true
49
+ }
50
+ }, /*#__PURE__*/React.createElement(Box, {
51
+ xcss: findReplaceWrapperStyles
52
+ }, /*#__PURE__*/React.createElement(FindReplace, _extends({
53
+ findText: findText,
54
+ replaceText: replaceText,
55
+ count: {
56
+ index,
57
+ total: numMatches
58
+ }
59
+ // Ignored via go/ees005
60
+ // eslint-disable-next-line react/jsx-props-no-spreading
61
+ }, props))));
62
+ };
63
+ export default injectIntl(FindReplaceDropdown);
@@ -5,7 +5,6 @@
5
5
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
6
6
  /* eslint-disable */
7
7
 
8
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4290
9
8
  import { css } from '@emotion/react';
10
9
  import { N40A, N50A, N60A } from '@atlaskit/theme/colors';
11
10
  export const searchMatchClass = 'search-match';
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import { ToolbarSize } from '@atlaskit/editor-common/types';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
4
5
  import keymapPlugin from './pm-plugins/keymap';
5
6
  import { createPlugin } from './pm-plugins/main';
6
7
  import { findReplacePluginKey } from './pm-plugins/plugin-key';
7
- import FindReplaceToolbarButtonWithState from './ui/FindReplaceToolbarButtonWithState';
8
+ import FindReplaceDropDownOrToolbarButtonWithState from './ui/FindReplaceDropDownOrToolbarButtonWithState';
8
9
  export var findReplacePlugin = function findReplacePlugin(_ref) {
9
10
  var _api$primaryToolbar;
10
11
  var props = _ref.config,
@@ -22,7 +23,7 @@ export var findReplacePlugin = function findReplacePlugin(_ref) {
22
23
  if (props !== null && props !== void 0 && props.twoLineEditorToolbar) {
23
24
  return null;
24
25
  } else {
25
- return /*#__PURE__*/React.createElement(FindReplaceToolbarButtonWithState, {
26
+ return /*#__PURE__*/React.createElement(FindReplaceDropDownOrToolbarButtonWithState, {
26
27
  popupsBoundariesElement: popupsBoundariesElement,
27
28
  popupsMountPoint: popupsMountPoint,
28
29
  popupsScrollableElement: popupsScrollableElement,
@@ -72,7 +73,7 @@ export var findReplacePlugin = function findReplacePlugin(_ref) {
72
73
  containerElement = _ref4.containerElement,
73
74
  dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent,
74
75
  isToolbarReducedSpacing = _ref4.isToolbarReducedSpacing;
75
- return /*#__PURE__*/React.createElement(FindReplaceToolbarButtonWithState, {
76
+ return /*#__PURE__*/React.createElement(FindReplaceDropDownOrToolbarButtonWithState, {
76
77
  popupsBoundariesElement: popupsBoundariesElement,
77
78
  popupsMountPoint: popupsMountPoint,
78
79
  popupsScrollableElement: popupsScrollableElement,
@@ -84,6 +85,31 @@ export var findReplacePlugin = function findReplacePlugin(_ref) {
84
85
  });
85
86
  }
86
87
  },
87
- primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
88
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
89
+ contentComponent: editorExperiment('platform_editor_controls', 'variant1', {
90
+ exposure: true
91
+ }) ? function (_ref5) {
92
+ var editorView = _ref5.editorView,
93
+ containerElement = _ref5.containerElement,
94
+ popupsMountPoint = _ref5.popupsMountPoint,
95
+ popupsBoundariesElement = _ref5.popupsBoundariesElement,
96
+ popupsScrollableElement = _ref5.popupsScrollableElement,
97
+ wrapperElement = _ref5.wrapperElement,
98
+ dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
99
+ var popupsMountPointEl = popupsMountPoint || ( // eslint-disable-next-line @atlaskit/editor/no-as-casting
100
+ wrapperElement === null || wrapperElement === void 0 ? void 0 : wrapperElement.querySelector("[data-editor-container='true']"));
101
+ return /*#__PURE__*/React.createElement(FindReplaceDropDownOrToolbarButtonWithState, {
102
+ popupsBoundariesElement: popupsBoundariesElement,
103
+ popupsMountPoint: popupsMountPointEl,
104
+ popupsScrollableElement: popupsScrollableElement || containerElement || undefined,
105
+ isToolbarReducedSpacing: false,
106
+ editorView: editorView,
107
+ containerElement: containerElement,
108
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
109
+ takeFullWidth: props === null || props === void 0 ? void 0 : props.takeFullWidth,
110
+ api: api,
111
+ doesNotHaveButton: true
112
+ });
113
+ } : undefined
88
114
  };
89
115
  };
@@ -8,7 +8,7 @@ import { initialState } from './main';
8
8
  import { findReplacePluginKey } from './plugin-key';
9
9
  import reducer from './reducer';
10
10
  import { createDecorations, findDecorationFromMatch, findMatches, findSearchIndex, isMatchAffectedByStep, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
11
- import { findUniqueItemsIn } from './utils/array'; // TODO: move into index export
11
+ import { findUniqueItemsIn } from './utils/array'; // TODO: ED-26959 - move into index export
12
12
 
13
13
  var handleDocChanged = function handleDocChanged(tr, pluginState) {
14
14
  var isActive = pluginState.isActive,
@@ -140,7 +140,6 @@ export var removeDecorationsFromSet = function removeDecorationsFromSet(decorati
140
140
  // there is a bug in prosemirror-view where it can't cope with deleting inline
141
141
  // decorations from a set in some cases (where there are multiple levels of nested
142
142
  // children arrays), and it deletes more decorations than it should
143
- // todo: ticket link
144
143
  var lostDecorations = findLostAdjacentDecorations(decorationsToRemove, prevDecorations, newDecorations);
145
144
  if (lostDecorations.length > 0) {
146
145
  decorationSet = decorationSet.add(doc, lostDecorations);
@@ -3,6 +3,7 @@ import React, { useLayoutEffect, useState } from 'react';
3
3
  import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import { blur, toggleMatchCase } from '../pm-plugins/commands';
5
5
  import { activateWithAnalytics, cancelSearchWithAnalytics, findNextWithAnalytics, findPrevWithAnalytics, findWithAnalytics, replaceAllWithAnalytics, replaceWithAnalytics } from '../pm-plugins/commands-with-analytics';
6
+ import FindReplaceDropdown from './FindReplaceDropdown';
6
7
  import FindReplaceToolbarButton from './FindReplaceToolbarButton';
7
8
 
8
9
  // light implementation of useSharedPluginState(). This is due to findreplace
@@ -41,7 +42,8 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
41
42
  dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
42
43
  takeFullWidth = _ref2.takeFullWidth,
43
44
  api = _ref2.api,
44
- isButtonHidden = _ref2.isButtonHidden;
45
+ isButtonHidden = _ref2.isButtonHidden,
46
+ doesNotHaveButton = _ref2.doesNotHaveButton;
45
47
  var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
46
48
  var _useSharedPluginState = useSharedPluginStateNoDebounce(api),
47
49
  findReplaceState = _useSharedPluginState.findReplaceState;
@@ -129,7 +131,8 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
129
131
  if (!findReplaceState) {
130
132
  return null;
131
133
  }
132
- return /*#__PURE__*/React.createElement(FindReplaceToolbarButton, {
134
+ var DropDownComponent = doesNotHaveButton ? FindReplaceDropdown : FindReplaceToolbarButton;
135
+ return /*#__PURE__*/React.createElement(DropDownComponent, {
133
136
  shouldMatchCase: findReplaceState.shouldMatchCase,
134
137
  onToggleMatchCase: handleToggleMatchCase,
135
138
  isActive: findReplaceState.isActive,
@@ -0,0 +1,61 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { injectIntl } from 'react-intl-next';
4
+ import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
5
+ import { ArrowKeyNavigationType, Dropdown } from '@atlaskit/editor-common/ui-menu';
6
+ import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
7
+ import { Box, xcss } from '@atlaskit/primitives';
8
+ import FindReplace from './FindReplace';
9
+ var findReplaceWrapperStyles = xcss({
10
+ display: 'flex',
11
+ flexDirection: 'column'
12
+ });
13
+
14
+ // Magic number taken from ../FindReplaceToolbarButton.tsx
15
+ var dropdownWidthNewDesign = 382;
16
+ var FindReplaceDropdown = function FindReplaceDropdown(props) {
17
+ var findText = props.findText,
18
+ replaceText = props.replaceText,
19
+ isActive = props.isActive,
20
+ index = props.index,
21
+ numMatches = props.numMatches,
22
+ popupsMountPoint = props.popupsMountPoint,
23
+ onCancel = props.onCancel;
24
+ if (!popupsMountPoint) {
25
+ return null;
26
+ }
27
+ return /*#__PURE__*/React.createElement(Dropdown, {
28
+ target: popupsMountPoint,
29
+ mountTo: popupsMountPoint,
30
+ forcePlacement: true,
31
+ alignX: 'right',
32
+ alignY: 'start',
33
+ offset: [4, 0],
34
+ isOpen: isActive,
35
+ handleEscapeKeydown: function handleEscapeKeydown() {
36
+ if (isActive) {
37
+ onCancel({
38
+ triggerMethod: TRIGGER_METHOD.KEYBOARD
39
+ });
40
+ }
41
+ },
42
+ fitWidth: dropdownWidthNewDesign,
43
+ zIndex: akEditorFloatingPanelZIndex,
44
+ arrowKeyNavigationProviderOptions: {
45
+ type: ArrowKeyNavigationType.MENU,
46
+ disableArrowKeyNavigation: true
47
+ }
48
+ }, /*#__PURE__*/React.createElement(Box, {
49
+ xcss: findReplaceWrapperStyles
50
+ }, /*#__PURE__*/React.createElement(FindReplace, _extends({
51
+ findText: findText,
52
+ replaceText: replaceText,
53
+ count: {
54
+ index: index,
55
+ total: numMatches
56
+ }
57
+ // Ignored via go/ees005
58
+ // eslint-disable-next-line react/jsx-props-no-spreading
59
+ }, props))));
60
+ };
61
+ export default injectIntl(FindReplaceDropdown);
@@ -6,7 +6,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
7
7
  /* eslint-disable */
8
8
 
9
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4290
10
9
  import { css } from '@emotion/react';
11
10
  import { N40A, N50A, N60A } from '@atlaskit/theme/colors';
12
11
  export var searchMatchClass = 'search-match';
@@ -34,6 +34,7 @@ export type FindReplaceToolbarButtonWithStateProps = {
34
34
  takeFullWidth?: boolean;
35
35
  api: ExtractInjectionAPI<FindReplacePlugin> | undefined;
36
36
  isButtonHidden?: boolean;
37
+ doesNotHaveButton?: boolean;
37
38
  };
38
39
  export type FindReplaceToolbarButtonActionProps = Omit<FindReplaceToolbarButtonWithStateProps, 'api'>;
39
40
  export type Match = {
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import type { FindReplaceToolbarButtonWithStateProps } from '../types';
3
- declare const _default: React.MemoExoticComponent<({ popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, isToolbarReducedSpacing, editorView, containerElement, dispatchAnalyticsEvent, takeFullWidth, api, isButtonHidden, }: FindReplaceToolbarButtonWithStateProps) => React.JSX.Element | null>;
3
+ declare const _default: React.MemoExoticComponent<({ popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, isToolbarReducedSpacing, editorView, containerElement, dispatchAnalyticsEvent, takeFullWidth, api, isButtonHidden, doesNotHaveButton, }: FindReplaceToolbarButtonWithStateProps) => React.JSX.Element | null>;
4
4
  export default _default;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { type WrappedComponentProps } from 'react-intl-next';
3
+ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
+ import type { FindReplaceProps } from './FindReplace';
5
+ export interface FindReplaceDropdownProps extends Omit<FindReplaceProps, 'count'> {
6
+ index: number;
7
+ numMatches: number;
8
+ isActive: boolean;
9
+ popupsMountPoint?: HTMLElement;
10
+ dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
11
+ }
12
+ declare const _default: React.FC<import("react-intl-next").WithIntlProps<FindReplaceDropdownProps & WrappedComponentProps>> & {
13
+ WrappedComponent: React.ComponentType<FindReplaceDropdownProps & WrappedComponentProps>;
14
+ };
15
+ export default _default;
@@ -34,6 +34,7 @@ export type FindReplaceToolbarButtonWithStateProps = {
34
34
  takeFullWidth?: boolean;
35
35
  api: ExtractInjectionAPI<FindReplacePlugin> | undefined;
36
36
  isButtonHidden?: boolean;
37
+ doesNotHaveButton?: boolean;
37
38
  };
38
39
  export type FindReplaceToolbarButtonActionProps = Omit<FindReplaceToolbarButtonWithStateProps, 'api'>;
39
40
  export type Match = {
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import type { FindReplaceToolbarButtonWithStateProps } from '../types';
3
- declare const _default: React.MemoExoticComponent<({ popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, isToolbarReducedSpacing, editorView, containerElement, dispatchAnalyticsEvent, takeFullWidth, api, isButtonHidden, }: FindReplaceToolbarButtonWithStateProps) => React.JSX.Element | null>;
3
+ declare const _default: React.MemoExoticComponent<({ popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, isToolbarReducedSpacing, editorView, containerElement, dispatchAnalyticsEvent, takeFullWidth, api, isButtonHidden, doesNotHaveButton, }: FindReplaceToolbarButtonWithStateProps) => React.JSX.Element | null>;
4
4
  export default _default;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { type WrappedComponentProps } from 'react-intl-next';
3
+ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
4
+ import type { FindReplaceProps } from './FindReplace';
5
+ export interface FindReplaceDropdownProps extends Omit<FindReplaceProps, 'count'> {
6
+ index: number;
7
+ numMatches: number;
8
+ isActive: boolean;
9
+ popupsMountPoint?: HTMLElement;
10
+ dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
11
+ }
12
+ declare const _default: React.FC<import("react-intl-next").WithIntlProps<FindReplaceDropdownProps & WrappedComponentProps>> & {
13
+ WrappedComponent: React.ComponentType<FindReplaceDropdownProps & WrappedComponentProps>;
14
+ };
15
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-find-replace",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "find replace plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,18 +33,19 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@atlaskit/button": "^21.1.0",
36
- "@atlaskit/editor-common": "^102.0.0",
37
- "@atlaskit/editor-plugin-analytics": "^2.1.0",
38
- "@atlaskit/editor-plugin-primary-toolbar": "^3.0.0",
36
+ "@atlaskit/editor-common": "^102.13.0",
37
+ "@atlaskit/editor-plugin-analytics": "^2.2.0",
38
+ "@atlaskit/editor-plugin-primary-toolbar": "^3.1.0",
39
39
  "@atlaskit/editor-prosemirror": "7.0.0",
40
40
  "@atlaskit/editor-shared-styles": "^3.4.0",
41
41
  "@atlaskit/form": "^12.0.0",
42
- "@atlaskit/icon": "^24.1.0",
42
+ "@atlaskit/icon": "^25.0.0",
43
43
  "@atlaskit/platform-feature-flags": "^1.1.0",
44
- "@atlaskit/primitives": "^14.1.0",
44
+ "@atlaskit/primitives": "^14.2.0",
45
45
  "@atlaskit/textfield": "^8.0.0",
46
46
  "@atlaskit/theme": "^18.0.0",
47
- "@atlaskit/tokens": "^4.3.0",
47
+ "@atlaskit/tmp-editor-statsig": "^4.2.0",
48
+ "@atlaskit/tokens": "^4.5.0",
48
49
  "@atlaskit/tooltip": "^20.0.0",
49
50
  "@babel/runtime": "^7.0.0",
50
51
  "@emotion/react": "^11.7.1",