@atlaskit/editor-plugin-find-replace 0.2.0 → 0.3.1

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,18 @@
1
1
  # @atlaskit/editor-plugin-find-replace
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#71136](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/71136) [`c803fea1e6a4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c803fea1e6a4) - Move all plugin translations to editor-common
8
+ - Updated dependencies
9
+
10
+ ## 0.3.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [#67595](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67595) [`3bb66071a333`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3bb66071a333) - [ux] ECA11Y-75: Updated UX/UI for "Find and Replace" modal window, added Focus trap to Find and Replace popup, added return focus to the search button when pressing ESC, update selected match and all matches highlighted colors, added Screan Reader announcements for repeated button clicks ( subtickets: ECA11Y-144, ECA11Y-145, ECA11Y-146, ECA11Y-147, ECA11Y-148, ECA11Y-149 )
15
+
3
16
  ## 0.2.0
4
17
 
5
18
  ### Minor Changes
@@ -5,13 +5,26 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.selectedSearchMatchClass = exports.searchMatchClass = exports.findReplaceStyles = void 0;
8
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("@emotion/react");
10
10
  var _colors = require("@atlaskit/theme/colors");
11
- var _templateObject;
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
+ var _css;
12
13
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage/preview */
13
14
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
15
+ /* eslint-disable */
14
16
  // TODO: https://product-fabric.atlassian.net/browse/DSP-4290
15
17
  var searchMatchClass = exports.searchMatchClass = 'search-match';
16
18
  var selectedSearchMatchClass = exports.selectedSearchMatchClass = 'selected-search-match';
17
- var findReplaceStyles = exports.findReplaceStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n background-color: ", ";\n }\n\n .", " {\n background-color: ", ";\n color: white;\n }\n"])), searchMatchClass, _colors.B75, selectedSearchMatchClass, _colors.B200);
19
+ var findReplaceStyles = exports.findReplaceStyles = (0, _react.css)((_css = {}, (0, _defineProperty2.default)(_css, ".".concat(searchMatchClass), (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace') ? {
20
+ borderRadius: '3px',
21
+ backgroundColor: "var(--ds-background-accent-teal-subtlest, #E7F9FF)",
22
+ boxShadow: "var(--ds-shadow-raised, ".concat("0 1px 1px 0 ".concat(_colors.N50A, ", 0 0 1px 0 ").concat(_colors.N60A), ")") + ', inset 0 0 0 1px ' + "var(--ds-border-input, ".concat("".concat(_colors.N40A), ")")
23
+ } : {
24
+ backgroundColor: _colors.B75
25
+ }), (0, _defineProperty2.default)(_css, ".".concat(selectedSearchMatchClass), (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace') ? {
26
+ backgroundColor: "var(--ds-background-accent-teal-subtle, #6CC3E0)"
27
+ } : {
28
+ backgroundColor: _colors.B200,
29
+ color: 'white'
30
+ }), _css));
@@ -18,6 +18,8 @@ var _debounce = _interopRequireDefault(require("lodash/debounce"));
18
18
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
19
19
  var _reactIntlNext = require("react-intl-next");
20
20
  var _analytics = require("@atlaskit/editor-common/analytics");
21
+ var _messages = require("@atlaskit/editor-common/messages");
22
+ var _form = require("@atlaskit/form");
21
23
  var _close = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/close"));
22
24
  var _keyboard = _interopRequireDefault(require("@atlaskit/icon/glyph/emoji/keyboard"));
23
25
  var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/hipchat/chevron-down"));
@@ -29,43 +31,6 @@ var _styles = require("./styles");
29
31
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
30
32
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */ /** @jsx jsx */
31
33
  var FIND_DEBOUNCE_MS = exports.FIND_DEBOUNCE_MS = 100;
32
- var messages = (0, _reactIntlNext.defineMessages)({
33
- find: {
34
- id: 'fabric.editor.find',
35
- defaultMessage: 'Find',
36
- description: 'The word or phrase to search for on the document'
37
- },
38
- matchCase: {
39
- id: 'fabric.editor.matchCase',
40
- defaultMessage: 'Match case',
41
- description: 'Toggle whether should also match case when searching for text'
42
- },
43
- findNext: {
44
- id: 'fabric.editor.findNext',
45
- defaultMessage: 'Find next',
46
- description: 'Locate the next occurrence of the word or phrase that was searched for'
47
- },
48
- findPrevious: {
49
- id: 'fabric.editor.findPrevious',
50
- defaultMessage: 'Find previous',
51
- description: 'Locate the previous occurrence of the word or phrase that was searched for'
52
- },
53
- closeFindReplaceDialog: {
54
- id: 'fabric.editor.closeFindReplaceDialog',
55
- defaultMessage: 'Close',
56
- description: 'Cancel search and close the "Find and Replace" dialog'
57
- },
58
- noResultsFound: {
59
- id: 'fabric.editor.noResultsFound',
60
- defaultMessage: 'No results',
61
- description: 'No matches were found for the word or phrase that was searched for'
62
- },
63
- resultsCount: {
64
- id: 'fabric.editor.resultsCount',
65
- description: 'Text for selected search match position and total results count',
66
- defaultMessage: '{selectedMatchPosition} of {totalResultsCount}'
67
- }
68
- });
69
34
  // eslint-disable-next-line @repo/internal/react/no-class-components
70
35
  var Find = /*#__PURE__*/function (_React$Component) {
71
36
  (0, _inherits2.default)(Find, _React$Component);
@@ -110,6 +75,7 @@ var Find = /*#__PURE__*/function (_React$Component) {
110
75
  onSynced && onSynced();
111
76
  _this.debouncedFind(value);
112
77
  });
78
+ _this.props.setFindTyped(true);
113
79
  });
114
80
  // throtlle between animation frames gives better experience on Enter compared to arbitrary value
115
81
  // it adjusts based on performance (and document size)
@@ -175,14 +141,15 @@ var Find = /*#__PURE__*/function (_React$Component) {
175
141
  }
176
142
  });
177
143
  var formatMessage = props.intl.formatMessage;
178
- _this.find = formatMessage(messages.find);
179
- _this.closeFindReplaceDialog = formatMessage(messages.closeFindReplaceDialog);
180
- _this.noResultsFound = formatMessage(messages.noResultsFound);
181
- _this.findNext = formatMessage(messages.findNext);
182
- _this.findPrevious = formatMessage(messages.findPrevious);
183
- _this.matchCase = formatMessage(messages.matchCase);
144
+ _this.find = formatMessage(_messages.findReplaceMessages.find);
145
+ _this.closeFindReplaceDialog = formatMessage(_messages.findReplaceMessages.closeFindReplaceDialog);
146
+ _this.noResultsFound = formatMessage(_messages.findReplaceMessages.noResultsFound);
147
+ _this.findNext = formatMessage(_messages.findReplaceMessages.findNext);
148
+ _this.findPrevious = formatMessage(_messages.findReplaceMessages.findPrevious);
149
+ _this.matchCase = formatMessage(_messages.findReplaceMessages.matchCase);
184
150
  _this.matchCaseIcon = (0, _react2.jsx)(_keyboard.default, {
185
- label: _this.matchCase
151
+ label: _this.matchCase,
152
+ size: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace') ? 'small' : 'medium'
186
153
  });
187
154
  _this.findNextIcon = (0, _react2.jsx)(_chevronDown.default, {
188
155
  label: _this.findNext
@@ -222,21 +189,19 @@ var Find = /*#__PURE__*/function (_React$Component) {
222
189
  }, {
223
190
  key: "componentDidUpdate",
224
191
  value: function componentDidUpdate(prevProps) {
225
- var _this3 = this;
192
+ var _this$state2,
193
+ _this3 = this;
226
194
  // focus on update if find text did not change
227
- if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace')) {
228
- var _this$state2;
229
- if (this.props.findText === ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.localFindText)) {
230
- this.focusFindTextfield();
231
- }
232
- if (this.props.findText !== prevProps.findText) {
233
- this.syncFindText(function () {
234
- // focus after input is synced if find text provided
235
- if (_this3.props.findText) {
236
- _this3.focusFindTextfield();
237
- }
238
- });
239
- }
195
+ if (this.props.findText === ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.localFindText)) {
196
+ this.focusFindTextfield();
197
+ }
198
+ if (this.props.findText !== prevProps.findText) {
199
+ this.syncFindText(function () {
200
+ // focus after input is synced if find text provided
201
+ if (_this3.props.findText) {
202
+ _this3.focusFindTextfield();
203
+ }
204
+ });
240
205
  }
241
206
  }
242
207
  }, {
@@ -254,54 +219,94 @@ var Find = /*#__PURE__*/function (_React$Component) {
254
219
  allowMatchCase = _this$props.allowMatchCase,
255
220
  shouldMatchCase = _this$props.shouldMatchCase,
256
221
  formatMessage = _this$props.intl.formatMessage;
257
- var resultsCount = formatMessage(messages.resultsCount, {
222
+ var resultsCount = formatMessage(_messages.findReplaceMessages.resultsCount, {
258
223
  selectedMatchPosition: count.index + 1,
259
224
  totalResultsCount: count.total
260
225
  });
261
- return (0, _react2.jsx)("div", {
262
- css: _styles.sectionWrapperStyles
263
- }, (0, _react2.jsx)(_textfield.default, {
264
- name: "find",
265
- appearance: "none",
266
- placeholder: this.find,
267
- value: this.state.localFindText,
268
- ref: this.findTextfieldRef,
269
- autoComplete: "off",
270
- onChange: this.handleFindChange,
271
- onKeyDown: this.handleFindKeyDown,
272
- onKeyUp: this.handleFindKeyUp,
273
- onBlur: this.props.onFindBlur,
274
- onCompositionStart: this.handleCompositionStart,
275
- onCompositionEnd: this.handleCompositionEnd
276
- }), (0, _react2.jsx)("div", {
277
- css: _styles.countWrapperStyles,
278
- "aria-live": "polite"
279
- }, findText && (0, _react2.jsx)("span", {
280
- "data-testid": "textfield-count",
281
- css: _styles.countStyles
282
- }, count.total === 0 ? this.noResultsFound : resultsCount)), allowMatchCase && (0, _react2.jsx)(_FindReplaceTooltipButton.FindReplaceTooltipButton, {
283
- title: this.matchCase,
284
- icon: this.matchCaseIcon,
285
- onClick: this.handleMatchCaseClick,
286
- isPressed: shouldMatchCase
287
- }), (0, _react2.jsx)(_FindReplaceTooltipButton.FindReplaceTooltipButton, {
288
- title: this.findNext,
289
- icon: this.findNextIcon,
290
- keymapDescription: 'Enter',
291
- onClick: this.handleFindNextClick,
292
- disabled: count.total <= 1
293
- }), (0, _react2.jsx)(_FindReplaceTooltipButton.FindReplaceTooltipButton, {
294
- title: this.findPrevious,
295
- icon: this.findPrevIcon,
296
- keymapDescription: 'Shift Enter',
297
- onClick: this.handleFindPrevClick,
298
- disabled: count.total <= 1
299
- }), (0, _react2.jsx)(_FindReplaceTooltipButton.FindReplaceTooltipButton, {
300
- title: this.closeFindReplaceDialog,
301
- icon: this.closeIcon,
302
- keymapDescription: 'Escape',
303
- onClick: this.clearSearch
304
- }));
226
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace')) {
227
+ var elemAfterInput = (0, _react2.jsx)("div", {
228
+ css: _styles.afterInputSection
229
+ }, (0, _react2.jsx)("div", {
230
+ "aria-live": "polite"
231
+ }, findText && (0, _react2.jsx)("span", {
232
+ "data-testid": "textfield-count",
233
+ css: [_styles.countStyles, _styles.countStylesAlternateStyles]
234
+ }, count.total === 0 ? this.noResultsFound : resultsCount)), allowMatchCase && (0, _react2.jsx)("div", {
235
+ css: _styles.matchCaseSection
236
+ }, (0, _react2.jsx)(_FindReplaceTooltipButton.FindReplaceTooltipButton, {
237
+ title: this.matchCase,
238
+ appearance: "default",
239
+ icon: this.matchCaseIcon,
240
+ onClick: this.handleMatchCaseClick,
241
+ isPressed: shouldMatchCase
242
+ })));
243
+ return (0, _react2.jsx)("div", {
244
+ css: [_styles.sectionWrapperStyles, _styles.sectionWrapperStylesAlternate]
245
+ }, (0, _react2.jsx)("div", {
246
+ css: _styles.textFieldWrapper
247
+ }, (0, _react2.jsx)(_form.Label, {
248
+ htmlFor: "find-text-field"
249
+ }, this.find), (0, _react2.jsx)(_textfield.default, {
250
+ name: "find",
251
+ id: "find-text-field",
252
+ appearance: "standard",
253
+ value: this.state.localFindText,
254
+ ref: this.findTextfieldRef,
255
+ autoComplete: "off",
256
+ onChange: this.handleFindChange,
257
+ onKeyDown: this.handleFindKeyDown,
258
+ onKeyUp: this.handleFindKeyUp,
259
+ onBlur: this.props.onFindBlur,
260
+ onCompositionStart: this.handleCompositionStart,
261
+ onCompositionEnd: this.handleCompositionEnd,
262
+ elemAfterInput: elemAfterInput
263
+ })));
264
+ } else {
265
+ return (0, _react2.jsx)("div", {
266
+ css: _styles.sectionWrapperStyles
267
+ }, (0, _react2.jsx)(_textfield.default, {
268
+ name: "find",
269
+ appearance: "none",
270
+ placeholder: this.find,
271
+ value: this.state.localFindText,
272
+ ref: this.findTextfieldRef,
273
+ autoComplete: "off",
274
+ onChange: this.handleFindChange,
275
+ onKeyDown: this.handleFindKeyDown,
276
+ onKeyUp: this.handleFindKeyUp,
277
+ onBlur: this.props.onFindBlur,
278
+ onCompositionStart: this.handleCompositionStart,
279
+ onCompositionEnd: this.handleCompositionEnd
280
+ }), (0, _react2.jsx)("div", {
281
+ css: _styles.countWrapperStyles,
282
+ "aria-live": "polite"
283
+ }, findText && (0, _react2.jsx)("span", {
284
+ "data-testid": "textfield-count",
285
+ css: _styles.countStyles
286
+ }, count.total === 0 ? this.noResultsFound : resultsCount)), allowMatchCase && (0, _react2.jsx)(_FindReplaceTooltipButton.FindReplaceTooltipButton, {
287
+ title: this.matchCase,
288
+ icon: this.matchCaseIcon,
289
+ onClick: this.handleMatchCaseClick,
290
+ isPressed: shouldMatchCase
291
+ }), (0, _react2.jsx)(_FindReplaceTooltipButton.FindReplaceTooltipButton, {
292
+ title: this.findNext,
293
+ icon: this.findNextIcon,
294
+ keymapDescription: 'Enter',
295
+ onClick: this.handleFindNextClick,
296
+ disabled: count.total <= 1
297
+ }), (0, _react2.jsx)(_FindReplaceTooltipButton.FindReplaceTooltipButton, {
298
+ title: this.findPrevious,
299
+ icon: this.findPrevIcon,
300
+ keymapDescription: 'Shift Enter',
301
+ onClick: this.handleFindPrevClick,
302
+ disabled: count.total <= 1
303
+ }), (0, _react2.jsx)(_FindReplaceTooltipButton.FindReplaceTooltipButton, {
304
+ title: this.closeFindReplaceDialog,
305
+ icon: this.closeIcon,
306
+ keymapDescription: 'Escape',
307
+ onClick: this.clearSearch
308
+ }));
309
+ }
305
310
  }
306
311
  }]);
307
312
  return Find;
@@ -14,6 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
14
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
15
  var _react = _interopRequireDefault(require("react"));
16
16
  var _react2 = require("@emotion/react");
17
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
18
  var _Find = _interopRequireDefault(require("./Find"));
18
19
  var _Replace = _interopRequireDefault(require("./Replace"));
19
20
  var _styles = require("./styles");
@@ -23,15 +24,45 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
23
24
  var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
24
25
  (0, _inherits2.default)(FindReplace, _React$PureComponent);
25
26
  var _super = _createSuper(FindReplace);
26
- function FindReplace() {
27
+ function FindReplace(props) {
27
28
  var _this;
28
29
  (0, _classCallCheck2.default)(this, FindReplace);
29
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
30
- args[_key] = arguments[_key];
31
- }
32
- _this = _super.call.apply(_super, [this].concat(args));
30
+ _this = _super.call(this, props);
33
31
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "findTextfield", null);
34
32
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "replaceTextfield", null);
33
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleTabNavigation", function (event) {
34
+ if (event.key === 'Tab') {
35
+ event.preventDefault();
36
+ var modalFindReplace = _this.modalRef.current;
37
+ if (!modalFindReplace || !modalFindReplace.contains(document.activeElement)) {
38
+ return;
39
+ }
40
+ var focusableElements = Array.from(modalFindReplace.querySelectorAll('[tabindex]:not([tabindex="-1"]), input, button')).filter(function (el) {
41
+ return el.getAttribute('tabindex') !== '-1';
42
+ });
43
+ var currentIndex = focusableElements.findIndex(function (el) {
44
+ return el === document.activeElement;
45
+ });
46
+ var isShiftPressed = event.shiftKey;
47
+ if (isShiftPressed) {
48
+ var prevIndex = (currentIndex - 1 + focusableElements.length) % focusableElements.length;
49
+ focusableElements[prevIndex].focus();
50
+ } else {
51
+ var nextIndex = (currentIndex + 1) % focusableElements.length;
52
+ focusableElements[nextIndex].focus();
53
+ }
54
+ }
55
+ });
56
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
57
+ findTyped: false
58
+ });
59
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setFindTyped", function (value) {
60
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace')) {
61
+ _this.setState({
62
+ findTyped: value
63
+ });
64
+ }
65
+ });
35
66
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setFindTextfieldRef", function (findTextfieldRef) {
36
67
  _this.findTextfield = findTextfieldRef.current;
37
68
  });
@@ -48,9 +79,26 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
48
79
  _this.replaceTextfield.focus();
49
80
  }
50
81
  });
82
+ _this.modalRef = /*#__PURE__*/_react.default.createRef();
51
83
  return _this;
52
84
  }
53
85
  (0, _createClass2.default)(FindReplace, [{
86
+ key: "componentDidMount",
87
+ value: function componentDidMount() {
88
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace')) {
89
+ // eslint-disable-next-line
90
+ window.addEventListener('keydown', this.handleTabNavigation);
91
+ }
92
+ }
93
+ }, {
94
+ key: "componentWillUnmount",
95
+ value: function componentWillUnmount() {
96
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace')) {
97
+ // eslint-disable-next-line
98
+ window.removeEventListener('keydown', this.handleTabNavigation);
99
+ }
100
+ }
101
+ }, {
54
102
  key: "render",
55
103
  value: function render() {
56
104
  var _this$props = this.props,
@@ -69,8 +117,10 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
69
117
  allowMatchCase = _this$props.allowMatchCase,
70
118
  shouldMatchCase = _this$props.shouldMatchCase,
71
119
  onToggleMatchCase = _this$props.onToggleMatchCase;
120
+ var focusToolbarButton = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace') ? this.props.focusToolbarButton || function () {} : function () {};
72
121
  return (0, _react2.jsx)("div", {
73
- css: _styles.wrapperStyles
122
+ ref: this.modalRef,
123
+ css: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace') ? [_styles.wrapperStyles, _styles.wrapperPaddingStyles] : _styles.wrapperStyles
74
124
  }, (0, _react2.jsx)(_Find.default, {
75
125
  allowMatchCase: allowMatchCase,
76
126
  shouldMatchCase: shouldMatchCase,
@@ -84,8 +134,10 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
84
134
  onFindNext: onFindNext,
85
135
  onFindTextfieldRefSet: this.setFindTextfieldRef,
86
136
  onCancel: onCancel,
87
- onArrowDown: this.setFocusToReplace
88
- }), (0, _react2.jsx)("hr", {
137
+ onArrowDown: this.setFocusToReplace,
138
+ findTyped: this.state.findTyped,
139
+ setFindTyped: this.setFindTyped
140
+ }), !(0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace') && (0, _react2.jsx)("hr", {
89
141
  css: _styles.ruleStyles,
90
142
  id: "replace-hr-element"
91
143
  }), (0, _react2.jsx)(_Replace.default, {
@@ -95,7 +147,14 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
95
147
  onReplaceAll: onReplaceAll,
96
148
  onReplaceTextfieldRefSet: this.setReplaceTextfieldRef,
97
149
  onArrowUp: this.setFocusToFind,
98
- dispatchAnalyticsEvent: dispatchAnalyticsEvent
150
+ onCancel: onCancel,
151
+ count: count,
152
+ onFindPrev: onFindPrev,
153
+ onFindNext: onFindNext,
154
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
155
+ findTyped: this.state.findTyped,
156
+ setFindTyped: this.setFindTyped,
157
+ focusToolbarButton: focusToolbarButton
99
158
  }));
100
159
  }
101
160
  }]);
@@ -19,9 +19,11 @@ var _react2 = require("@emotion/react");
19
19
  var _reactIntlNext = require("react-intl-next");
20
20
  var _analytics = require("@atlaskit/editor-common/analytics");
21
21
  var _keymaps = require("@atlaskit/editor-common/keymaps");
22
+ var _messages = require("@atlaskit/editor-common/messages");
22
23
  var _uiMenu = require("@atlaskit/editor-common/ui-menu");
23
24
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
24
25
  var _search = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/search"));
26
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
25
27
  var _FindReplace = _interopRequireDefault(require("./FindReplace"));
26
28
  var _templateObject, _templateObject2, _templateObject3;
27
29
  /* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
@@ -31,13 +33,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
31
33
  var toolbarButtonWrapper = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex: 1 1 auto;\n flex-grow: 0;\n justify-content: flex-end;\n align-items: center;\n padding: 0 ", ";\n @media (max-width: ", "px) {\n justify-content: center;\n padding: 0;\n }\n"])), "var(--ds-space-100, 8px)", _editorSharedStyles.akEditorMobileMaxWidth);
32
34
  var toolbarButtonWrapperFullWith = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n flex-grow: 1;\n"])));
33
35
  var wrapper = (0, _react2.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n"])));
34
- var messages = (0, _reactIntlNext.defineMessages)({
35
- findReplaceToolbarButton: {
36
- id: 'fabric.editor.findReplaceToolbarButton',
37
- defaultMessage: 'Find and replace',
38
- description: '"Find" highlights all instances of a word or phrase on the document, and "Replace" changes one or all of those instances to something else'
39
- }
40
- });
36
+ var dropdownWidthNewDesign = 382;
37
+ var dropdownWidthOldDesign = 352;
41
38
  // eslint-disable-next-line @repo/internal/react/no-class-components
42
39
  var FindReplaceToolbarButton = /*#__PURE__*/function (_React$PureComponent) {
43
40
  (0, _inherits2.default)(FindReplaceToolbarButton, _React$PureComponent);
@@ -49,15 +46,30 @@ var FindReplaceToolbarButton = /*#__PURE__*/function (_React$PureComponent) {
49
46
  args[_key] = arguments[_key];
50
47
  }
51
48
  _this = _super.call.apply(_super, [this].concat(args));
49
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
50
+ openedByClick: false
51
+ });
52
52
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "toggleOpen", function () {
53
53
  if (_this.props.isActive) {
54
54
  _this.props.onCancel({
55
55
  triggerMethod: _analytics.TRIGGER_METHOD.TOOLBAR
56
56
  });
57
57
  } else {
58
+ _this.setState({
59
+ openedByClick: true
60
+ });
58
61
  _this.props.onActivate();
59
62
  }
60
63
  });
64
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "focusToolbarButton", function () {
65
+ if (_this.state.openedByClick && _this.toolbarButtonRef.current) {
66
+ _this.toolbarButtonRef.current.focus();
67
+ }
68
+ _this.setState({
69
+ openedByClick: false
70
+ });
71
+ });
72
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "toolbarButtonRef", /*#__PURE__*/_react.default.createRef());
61
73
  return _this;
62
74
  }
63
75
  (0, _createClass2.default)(FindReplaceToolbarButton, [{
@@ -76,7 +88,7 @@ var FindReplaceToolbarButton = /*#__PURE__*/function (_React$PureComponent) {
76
88
  numMatches = _this$props.numMatches,
77
89
  formatMessage = _this$props.intl.formatMessage,
78
90
  takeFullWidth = _this$props.takeFullWidth;
79
- var title = formatMessage(messages.findReplaceToolbarButton);
91
+ var title = formatMessage(_messages.findReplaceMessages.findReplaceToolbarButton);
80
92
  var stackBelowOtherEditorFloatingPanels = _editorSharedStyles.akEditorFloatingPanelZIndex - 1;
81
93
  var keymap = (0, _keymaps.findKeymapByDescription)('Find');
82
94
  return (0, _react2.jsx)("div", {
@@ -91,9 +103,17 @@ var FindReplaceToolbarButton = /*#__PURE__*/function (_React$PureComponent) {
91
103
  _this2.props.onCancel({
92
104
  triggerMethod: _analytics.TRIGGER_METHOD.KEYBOARD
93
105
  });
106
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace')) {
107
+ if (_this2.state.openedByClick && _this2.toolbarButtonRef.current) {
108
+ _this2.toolbarButtonRef.current.focus();
109
+ }
110
+ _this2.setState({
111
+ openedByClick: false
112
+ });
113
+ }
94
114
  }
95
115
  },
96
- fitWidth: 352,
116
+ fitWidth: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace') ? dropdownWidthNewDesign : dropdownWidthOldDesign,
97
117
  zIndex: stackBelowOtherEditorFloatingPanels,
98
118
  arrowKeyNavigationProviderOptions: {
99
119
  type: _uiMenu.ArrowKeyNavigationType.MENU,
@@ -114,7 +134,8 @@ var FindReplaceToolbarButton = /*#__PURE__*/function (_React$PureComponent) {
114
134
  "aria-expanded": isActive,
115
135
  "aria-haspopup": true,
116
136
  "aria-label": keymap ? (0, _keymaps.tooltip)(keymap, title) : title,
117
- "aria-keyshortcuts": (0, _keymaps.getAriaKeyshortcuts)(keymap)
137
+ "aria-keyshortcuts": (0, _keymaps.getAriaKeyshortcuts)(keymap),
138
+ ref: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-find-replace') ? this.toolbarButtonRef : null
118
139
  })
119
140
  }, (0, _react2.jsx)("div", {
120
141
  css: wrapper
@@ -124,7 +145,8 @@ var FindReplaceToolbarButton = /*#__PURE__*/function (_React$PureComponent) {
124
145
  count: {
125
146
  index: index,
126
147
  total: numMatches
127
- }
148
+ },
149
+ focusToolbarButton: this.focusToolbarButton
128
150
  }, this.props)))));
129
151
  }
130
152
  }]);
@@ -46,7 +46,8 @@ var FindReplaceTooltipButton = exports.FindReplaceTooltipButton = /*#__PURE__*/f
46
46
  icon = _this$props.icon,
47
47
  keymapDescription = _this$props.keymapDescription,
48
48
  disabled = _this$props.disabled,
49
- isPressed = _this$props.isPressed;
49
+ isPressed = _this$props.isPressed,
50
+ appearance = _this$props.appearance;
50
51
  var pressedProps = _objectSpread({}, typeof isPressed === 'boolean' && {
51
52
  'aria-pressed': isPressed
52
53
  });
@@ -58,8 +59,9 @@ var FindReplaceTooltipButton = exports.FindReplaceTooltipButton = /*#__PURE__*/f
58
59
  hideTooltipOnClick: true,
59
60
  position: 'top'
60
61
  }, /*#__PURE__*/_react.default.createElement(_standardButton.default, (0, _extends2.default)({
62
+ id: "afterInputSection",
61
63
  label: title,
62
- appearance: "subtle",
64
+ appearance: appearance,
63
65
  testId: title,
64
66
  ref: this.buttonRef,
65
67
  iconBefore: icon,
@@ -73,5 +75,6 @@ var FindReplaceTooltipButton = exports.FindReplaceTooltipButton = /*#__PURE__*/f
73
75
  return FindReplaceTooltipButton;
74
76
  }(_react.default.PureComponent);
75
77
  (0, _defineProperty2.default)(FindReplaceTooltipButton, "defaultProps", {
76
- keymapDescription: 'no-keymap'
78
+ keymapDescription: 'no-keymap',
79
+ appearance: 'subtle'
77
80
  });