@atlaskit/editor-plugin-find-replace 6.0.9 → 6.1.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 +18 -0
- package/dist/cjs/ui/FindReplace.js +4 -61
- package/dist/cjs/ui/Replace.js +232 -310
- package/dist/es2019/ui/FindReplace.js +4 -53
- package/dist/es2019/ui/Replace.js +213 -302
- package/dist/esm/ui/FindReplace.js +4 -61
- package/dist/esm/ui/Replace.js +234 -317
- package/dist/types/ui/FindReplace.d.ts +0 -7
- package/dist/types/ui/Replace.d.ts +0 -11
- package/dist/types-ts4.5/ui/FindReplace.d.ts +0 -7
- package/dist/types-ts4.5/ui/Replace.d.ts +0 -11
- package/package.json +9 -12
- package/dist/cjs/ui/ReplaceNext.js +0 -277
- package/dist/es2019/ui/ReplaceNext.js +0 -242
- package/dist/esm/ui/ReplaceNext.js +0 -267
- package/dist/types/ui/ReplaceNext.d.ts +0 -39
- package/dist/types-ts4.5/ui/ReplaceNext.d.ts +0 -39
|
@@ -9,11 +9,9 @@ import React from 'react';
|
|
|
9
9
|
|
|
10
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
11
|
import { jsx } from '@emotion/react';
|
|
12
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
13
|
import Find from './Find';
|
|
15
14
|
import Replace from './Replace';
|
|
16
|
-
import ReplaceNext from './ReplaceNext';
|
|
17
15
|
import { ruleStyles, wrapperPaddingStyles, wrapperStyles } from './ui-styles';
|
|
18
16
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
19
17
|
class FindReplace extends React.PureComponent {
|
|
@@ -21,32 +19,6 @@ class FindReplace extends React.PureComponent {
|
|
|
21
19
|
super(props);
|
|
22
20
|
_defineProperty(this, "findTextfield", null);
|
|
23
21
|
_defineProperty(this, "replaceTextfield", null);
|
|
24
|
-
/**
|
|
25
|
-
* Delete this function on cleanup of
|
|
26
|
-
* editor_a11y_refactor_find_replace_style
|
|
27
|
-
*/
|
|
28
|
-
_defineProperty(this, "handleTabNavigation", event => {
|
|
29
|
-
if (fg('editor_a11y_refactor_find_replace_style')) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (event.key === 'Tab') {
|
|
33
|
-
event.preventDefault();
|
|
34
|
-
const modalFindReplace = this.modalRef.current;
|
|
35
|
-
if (!modalFindReplace || !modalFindReplace.contains(document.activeElement)) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const focusableElements = Array.from(modalFindReplace.querySelectorAll('[tabindex]:not([tabindex="-1"]), input, button')).filter(el => el.getAttribute('tabindex') !== '-1');
|
|
39
|
-
const currentIndex = focusableElements.findIndex(el => el === document.activeElement);
|
|
40
|
-
const isShiftPressed = event.shiftKey;
|
|
41
|
-
if (isShiftPressed) {
|
|
42
|
-
const prevIndex = (currentIndex - 1 + focusableElements.length) % focusableElements.length;
|
|
43
|
-
focusableElements[prevIndex].focus();
|
|
44
|
-
} else {
|
|
45
|
-
const nextIndex = (currentIndex + 1) % focusableElements.length;
|
|
46
|
-
focusableElements[nextIndex].focus();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
22
|
_defineProperty(this, "state", {
|
|
51
23
|
findTyped: false
|
|
52
24
|
});
|
|
@@ -73,14 +45,6 @@ class FindReplace extends React.PureComponent {
|
|
|
73
45
|
});
|
|
74
46
|
this.modalRef = /*#__PURE__*/React.createRef();
|
|
75
47
|
}
|
|
76
|
-
componentDidMount() {
|
|
77
|
-
// eslint-disable-next-line
|
|
78
|
-
window.addEventListener('keydown', this.handleTabNavigation);
|
|
79
|
-
}
|
|
80
|
-
componentWillUnmount() {
|
|
81
|
-
// eslint-disable-next-line
|
|
82
|
-
window.removeEventListener('keydown', this.handleTabNavigation);
|
|
83
|
-
}
|
|
84
48
|
render() {
|
|
85
49
|
const {
|
|
86
50
|
findText,
|
|
@@ -102,7 +66,9 @@ class FindReplace extends React.PureComponent {
|
|
|
102
66
|
} = this.props;
|
|
103
67
|
const focusToolbarButton = this.props.focusToolbarButton || (() => {});
|
|
104
68
|
return jsx("div", {
|
|
105
|
-
role: 'dialog'
|
|
69
|
+
role: 'dialog'
|
|
70
|
+
// eslint-disable-next-line @atlassian/i18n/no-literal-string-in-jsx
|
|
71
|
+
,
|
|
106
72
|
"aria-label": 'Find and Replace',
|
|
107
73
|
"aria-modal": false,
|
|
108
74
|
ref: this.modalRef
|
|
@@ -129,22 +95,7 @@ class FindReplace extends React.PureComponent {
|
|
|
129
95
|
role: "presentation",
|
|
130
96
|
css: ruleStyles,
|
|
131
97
|
id: "replace-hr-element"
|
|
132
|
-
}),
|
|
133
|
-
canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
|
|
134
|
-
replaceText: replaceText,
|
|
135
|
-
onReplace: onReplace,
|
|
136
|
-
onReplaceAll: onReplaceAll,
|
|
137
|
-
onReplaceTextfieldRefSet: this.setReplaceTextfieldRef,
|
|
138
|
-
onArrowUp: this.setFocusToFind,
|
|
139
|
-
onCancel: onCancel,
|
|
140
|
-
count: count,
|
|
141
|
-
onFindPrev: onFindPrev,
|
|
142
|
-
onFindNext: onFindNext,
|
|
143
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
144
|
-
findTyped: this.state.findTyped,
|
|
145
|
-
setFindTyped: this.setFindTyped,
|
|
146
|
-
focusToolbarButton: focusToolbarButton
|
|
147
|
-
}) : jsx(Replace, {
|
|
98
|
+
}), jsx(Replace, {
|
|
148
99
|
canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
|
|
149
100
|
replaceText: replaceText,
|
|
150
101
|
onReplace: onReplace,
|
|
@@ -1,332 +1,243 @@
|
|
|
1
|
-
import
|
|
2
|
-
/* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
|
|
3
|
-
/**
|
|
4
|
-
* @jsxRuntime classic
|
|
5
|
-
* @jsx jsx
|
|
6
|
-
*/
|
|
7
|
-
import React, { Fragment } from 'react';
|
|
8
|
-
|
|
9
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
|
-
import { css, jsx } from '@emotion/react';
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
11
2
|
import { injectIntl } from 'react-intl-next';
|
|
12
3
|
import Button from '@atlaskit/button/new';
|
|
13
4
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
14
5
|
import { findReplaceMessages as messages } from '@atlaskit/editor-common/messages';
|
|
15
|
-
import {
|
|
16
|
-
import { Label, ValidMessage } from '@atlaskit/form';
|
|
6
|
+
import { ValidMessage } from '@atlaskit/form';
|
|
17
7
|
import ChevronDownIcon from '@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down';
|
|
18
8
|
import ChevronUpIcon from '@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up';
|
|
19
9
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
20
|
-
import { Inline, xcss } from '@atlaskit/primitives';
|
|
10
|
+
import { Box, Inline, Text, xcss } from '@atlaskit/primitives';
|
|
21
11
|
import Textfield from '@atlaskit/textfield';
|
|
22
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
23
13
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
display: 'flex',
|
|
27
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
28
|
-
'& > *': {
|
|
29
|
-
display: 'inline-flex',
|
|
30
|
-
height: '32px',
|
|
31
|
-
flex: '0 0 auto'
|
|
32
|
-
},
|
|
33
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
34
|
-
'& > [data-ds--text-field--container]': {
|
|
35
|
-
display: 'flex',
|
|
36
|
-
flex: '1 1 auto'
|
|
37
|
-
}
|
|
14
|
+
const replaceContainerStyles = xcss({
|
|
15
|
+
padding: 'space.100'
|
|
38
16
|
});
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
height: 'unset'
|
|
45
|
-
}
|
|
17
|
+
const replaceWithLabelStyle = xcss({
|
|
18
|
+
paddingBottom: 'space.050'
|
|
19
|
+
});
|
|
20
|
+
const actionButtonContainerStyles = xcss({
|
|
21
|
+
paddingTop: 'space.200'
|
|
46
22
|
});
|
|
47
|
-
const
|
|
23
|
+
const actionButtonParentInlineStyles = xcss({
|
|
48
24
|
justifyContent: 'space-between',
|
|
49
|
-
|
|
50
|
-
fontSize: relativeFontSizeToBase16(14)
|
|
25
|
+
flexDirection: 'row-reverse'
|
|
51
26
|
});
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
27
|
+
const actionButtonParentInlineStylesNew = xcss({
|
|
28
|
+
justifyContent: 'space-between',
|
|
29
|
+
flexDirection: 'row-reverse',
|
|
30
|
+
flexWrap: 'wrap'
|
|
55
31
|
});
|
|
56
|
-
const
|
|
57
|
-
|
|
32
|
+
const actionButtonInlineStyles = xcss({
|
|
33
|
+
gap: 'space.075'
|
|
58
34
|
});
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
marginLeft: 'auto'
|
|
35
|
+
const closeButtonInlineStyles = xcss({
|
|
36
|
+
marginRight: 'auto'
|
|
62
37
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
38
|
+
const Replace = ({
|
|
39
|
+
canReplace,
|
|
40
|
+
replaceText: initialReplaceText,
|
|
41
|
+
onReplace,
|
|
42
|
+
onReplaceAll,
|
|
43
|
+
onReplaceTextfieldRefSet,
|
|
44
|
+
onArrowUp,
|
|
45
|
+
onCancel,
|
|
46
|
+
count,
|
|
47
|
+
onFindNext,
|
|
48
|
+
onFindPrev,
|
|
49
|
+
dispatchAnalyticsEvent,
|
|
50
|
+
setFindTyped,
|
|
51
|
+
findTyped,
|
|
52
|
+
focusToolbarButton,
|
|
53
|
+
intl: {
|
|
54
|
+
formatMessage
|
|
55
|
+
}
|
|
56
|
+
}) => {
|
|
57
|
+
const [replaceText, setReplaceText] = useState(initialReplaceText || '');
|
|
58
|
+
const [isComposing, setIsComposing] = useState(false);
|
|
59
|
+
const [isHelperMessageVisible, setIsHelperMessageVisible] = useState(false);
|
|
60
|
+
const [fakeSuccessReplacementMessageUpdate, setFakeSuccessReplacementMessageUpdate] = useState(false);
|
|
61
|
+
const [replaceCount, setReplaceCount] = useState(0);
|
|
62
|
+
const replaceTextfieldRef = useRef(null);
|
|
63
|
+
const successReplacementMessageRef = useRef(null);
|
|
64
|
+
const replaceWith = formatMessage(messages.replaceWith);
|
|
65
|
+
const replaceAll = formatMessage(messages.replaceAll);
|
|
66
|
+
const findPrevious = formatMessage(messages.findPrevious);
|
|
67
|
+
const closeFindReplaceDialog = formatMessage(messages.closeFindReplaceDialog);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
onReplaceTextfieldRefSet(replaceTextfieldRef);
|
|
70
|
+
}, [onReplaceTextfieldRefSet]);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
setReplaceText(initialReplaceText || '');
|
|
73
|
+
}, [initialReplaceText]);
|
|
74
|
+
const skipWhileComposing = fn => {
|
|
75
|
+
if (!isComposing) {
|
|
74
76
|
fn();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const triggerSuccessReplacementMessageUpdate = currentReplaceCount => {
|
|
80
|
+
if (replaceCount === currentReplaceCount) {
|
|
81
|
+
setFakeSuccessReplacementMessageUpdate(!fakeSuccessReplacementMessageUpdate);
|
|
82
|
+
}
|
|
83
|
+
if (successReplacementMessageRef.current) {
|
|
84
|
+
const ariaLiveRegion = successReplacementMessageRef.current.querySelector('[aria-live="polite"]');
|
|
85
|
+
ariaLiveRegion === null || ariaLiveRegion === void 0 ? void 0 : ariaLiveRegion.removeAttribute('aria-live');
|
|
86
|
+
ariaLiveRegion === null || ariaLiveRegion === void 0 ? void 0 : ariaLiveRegion.setAttribute('aria-live', 'polite');
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const handleReplaceClick = () => skipWhileComposing(() => {
|
|
90
|
+
onReplace({
|
|
91
|
+
triggerMethod: TRIGGER_METHOD.BUTTON,
|
|
92
|
+
replaceText
|
|
75
93
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
triggerSuccessReplacementMessageUpdate(1);
|
|
95
|
+
setIsHelperMessageVisible(true);
|
|
96
|
+
setReplaceCount(1);
|
|
97
|
+
setFindTyped(false);
|
|
98
|
+
});
|
|
99
|
+
const handleReplaceChange = event => skipWhileComposing(() => {
|
|
100
|
+
updateReplaceValue(event.target.value);
|
|
101
|
+
});
|
|
102
|
+
const updateReplaceValue = text => {
|
|
103
|
+
if (dispatchAnalyticsEvent) {
|
|
104
|
+
dispatchAnalyticsEvent({
|
|
105
|
+
eventType: EVENT_TYPE.TRACK,
|
|
106
|
+
action: ACTION.CHANGED_REPLACEMENT_TEXT,
|
|
107
|
+
actionSubject: ACTION_SUBJECT.FIND_REPLACE_DIALOG
|
|
80
108
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.props.setFindTyped(false);
|
|
89
|
-
}));
|
|
90
|
-
_defineProperty(this, "handleReplaceChange", event => this.skipWhileComposing(() => {
|
|
91
|
-
this.updateReplaceValue(event.target.value);
|
|
92
|
-
}));
|
|
93
|
-
_defineProperty(this, "updateReplaceValue", replaceText => {
|
|
94
|
-
const {
|
|
95
|
-
dispatchAnalyticsEvent
|
|
96
|
-
} = this.props;
|
|
97
|
-
if (dispatchAnalyticsEvent) {
|
|
98
|
-
dispatchAnalyticsEvent({
|
|
99
|
-
eventType: EVENT_TYPE.TRACK,
|
|
100
|
-
action: ACTION.CHANGED_REPLACEMENT_TEXT,
|
|
101
|
-
actionSubject: ACTION_SUBJECT.FIND_REPLACE_DIALOG
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
this.setState({
|
|
109
|
+
}
|
|
110
|
+
setReplaceText(text);
|
|
111
|
+
};
|
|
112
|
+
const handleReplaceKeyDown = event => skipWhileComposing(() => {
|
|
113
|
+
if (event.key === 'Enter') {
|
|
114
|
+
onReplace({
|
|
115
|
+
triggerMethod: TRIGGER_METHOD.KEYBOARD,
|
|
105
116
|
replaceText
|
|
106
117
|
});
|
|
118
|
+
} else if (event.key === 'ArrowUp') {
|
|
119
|
+
onArrowUp();
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
const handleReplaceAllClick = () => skipWhileComposing(() => {
|
|
123
|
+
onReplaceAll({
|
|
124
|
+
replaceText
|
|
107
125
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
replaceCount: this.props.count.totalReplaceable
|
|
130
|
-
});
|
|
131
|
-
} else {
|
|
132
|
-
this.triggerSuccessReplacementMessageUpdate(this.props.count.total);
|
|
133
|
-
this.setState({
|
|
134
|
-
replaceCount: this.props.count.total
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
this.props.setFindTyped(false);
|
|
138
|
-
}));
|
|
139
|
-
_defineProperty(this, "handleCompositionStart", () => {
|
|
140
|
-
this.setState({
|
|
141
|
-
isComposing: true
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
_defineProperty(this, "handleCompositionEnd", event => {
|
|
145
|
-
this.setState({
|
|
146
|
-
isComposing: false
|
|
147
|
-
});
|
|
148
|
-
// type for React.CompositionEvent doesn't set type for target correctly
|
|
149
|
-
this.updateReplaceValue(event.target.value);
|
|
150
|
-
});
|
|
151
|
-
_defineProperty(this, "clearSearch", () => {
|
|
152
|
-
this.props.onCancel({
|
|
153
|
-
triggerMethod: TRIGGER_METHOD.BUTTON
|
|
154
|
-
});
|
|
155
|
-
this.props.focusToolbarButton && this.props.focusToolbarButton();
|
|
156
|
-
});
|
|
157
|
-
_defineProperty(this, "handleFindNextClick", () => {
|
|
158
|
-
if (this.isComposing) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
this.props.onFindNext({
|
|
162
|
-
triggerMethod: TRIGGER_METHOD.BUTTON
|
|
163
|
-
});
|
|
126
|
+
setIsHelperMessageVisible(true);
|
|
127
|
+
if (count.totalReplaceable && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
128
|
+
triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
|
|
129
|
+
setReplaceCount(count.totalReplaceable);
|
|
130
|
+
} else {
|
|
131
|
+
triggerSuccessReplacementMessageUpdate(count.total);
|
|
132
|
+
setReplaceCount(count.total);
|
|
133
|
+
}
|
|
134
|
+
setFindTyped(false);
|
|
135
|
+
});
|
|
136
|
+
const handleCompositionStart = () => {
|
|
137
|
+
setIsComposing(true);
|
|
138
|
+
};
|
|
139
|
+
const handleCompositionEnd = event => {
|
|
140
|
+
setIsComposing(false);
|
|
141
|
+
// type for React.CompositionEvent doesn't set type for target correctly
|
|
142
|
+
updateReplaceValue(event.target.value);
|
|
143
|
+
};
|
|
144
|
+
const clearSearch = () => {
|
|
145
|
+
onCancel({
|
|
146
|
+
triggerMethod: TRIGGER_METHOD.BUTTON
|
|
164
147
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
148
|
+
focusToolbarButton();
|
|
149
|
+
};
|
|
150
|
+
const handleFindNextClick = () => {
|
|
151
|
+
if (!isComposing) {
|
|
152
|
+
onFindNext({
|
|
170
153
|
triggerMethod: TRIGGER_METHOD.BUTTON
|
|
171
154
|
});
|
|
172
|
-
});
|
|
173
|
-
const {
|
|
174
|
-
replaceText: _replaceText,
|
|
175
|
-
intl: {
|
|
176
|
-
formatMessage
|
|
177
|
-
}
|
|
178
|
-
} = props;
|
|
179
|
-
this.state = {
|
|
180
|
-
replaceText: _replaceText || '',
|
|
181
|
-
isComposing: false,
|
|
182
|
-
isHelperMessageVisible: false,
|
|
183
|
-
fakeSuccessReplacementMessageUpdate: false,
|
|
184
|
-
replaceCount: 0
|
|
185
|
-
};
|
|
186
|
-
this.replace = formatMessage(messages.replace);
|
|
187
|
-
this.replaceWith = formatMessage(messages.replaceWith);
|
|
188
|
-
this.replaceAll = formatMessage(messages.replaceAll);
|
|
189
|
-
this.findNext = formatMessage(messages.findNext);
|
|
190
|
-
this.findPrevious = formatMessage(messages.findPrevious);
|
|
191
|
-
this.closeFindReplaceDialog = formatMessage(messages.closeFindReplaceDialog);
|
|
192
|
-
}
|
|
193
|
-
componentDidMount() {
|
|
194
|
-
this.props.onReplaceTextfieldRefSet(this.replaceTextfieldRef);
|
|
195
|
-
}
|
|
196
|
-
componentDidUpdate({
|
|
197
|
-
replaceText: prevReplaceText
|
|
198
|
-
}) {
|
|
199
|
-
const {
|
|
200
|
-
replaceText
|
|
201
|
-
} = this.props;
|
|
202
|
-
if (replaceText && replaceText !== prevReplaceText) {
|
|
203
|
-
this.setState({
|
|
204
|
-
replaceText,
|
|
205
|
-
isComposing: false
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
const findTextField = document.getElementById('find-text-field');
|
|
209
|
-
const replaceButton = document.getElementById('replace-button');
|
|
210
|
-
const replaceAllButton = document.getElementById('replaceAll-button');
|
|
211
|
-
if (((replaceButton === null || replaceButton === void 0 ? void 0 : replaceButton.tabIndex) === -1 || (replaceAllButton === null || replaceAllButton === void 0 ? void 0 : replaceAllButton.tabIndex) === -1) && findTextField) {
|
|
212
|
-
findTextField.focus();
|
|
213
155
|
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
fakeSuccessReplacementMessageUpdate: !this.state.fakeSuccessReplacementMessageUpdate
|
|
156
|
+
};
|
|
157
|
+
const handleFindPrevClick = () => {
|
|
158
|
+
if (!isComposing) {
|
|
159
|
+
onFindPrev({
|
|
160
|
+
triggerMethod: TRIGGER_METHOD.BUTTON
|
|
220
161
|
});
|
|
221
162
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
},
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
})), jsx(Inline, {
|
|
303
|
-
space: "space.075"
|
|
304
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
305
|
-
,
|
|
306
|
-
xcss: xcss({
|
|
307
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
308
|
-
paddingInlineStart: 'space.050',
|
|
309
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
310
|
-
paddingInlineEnd: 'space.025'
|
|
311
|
-
})
|
|
312
|
-
}, jsx(Button, {
|
|
313
|
-
testId: this.replace,
|
|
314
|
-
id: "replace-button",
|
|
315
|
-
onClick: this.handleReplaceClick,
|
|
316
|
-
isDisabled: !canReplace
|
|
317
|
-
}, this.replace), jsx(Button, {
|
|
318
|
-
appearance: "primary",
|
|
319
|
-
testId: this.replaceAll,
|
|
320
|
-
id: "replaceAll-button",
|
|
321
|
-
onClick: this.handleReplaceAllClick,
|
|
322
|
-
isDisabled: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
|
|
323
|
-
}, this.replaceAll))), jsx("div", {
|
|
324
|
-
css: orderZeroStyles
|
|
325
|
-
}, jsx(Button, {
|
|
326
|
-
appearance: "subtle",
|
|
327
|
-
testId: this.closeFindReplaceDialog,
|
|
328
|
-
onClick: this.clearSearch
|
|
329
|
-
}, this.closeFindReplaceDialog))));
|
|
330
|
-
}
|
|
331
|
-
}
|
|
163
|
+
};
|
|
164
|
+
const resultsReplace = formatMessage(messages.replaceSuccess, {
|
|
165
|
+
numberOfMatches: replaceCount
|
|
166
|
+
});
|
|
167
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
168
|
+
xcss: replaceContainerStyles
|
|
169
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
170
|
+
xcss: replaceWithLabelStyle
|
|
171
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
172
|
+
id: "replace-text-field-label",
|
|
173
|
+
size: "medium",
|
|
174
|
+
weight: "bold",
|
|
175
|
+
color: "color.text.subtle"
|
|
176
|
+
}, replaceWith)), /*#__PURE__*/React.createElement(Textfield, {
|
|
177
|
+
name: "replace",
|
|
178
|
+
"aria-labelledby": "replace-text-field-label",
|
|
179
|
+
testId: "replace-field",
|
|
180
|
+
appearance: "standard",
|
|
181
|
+
defaultValue: replaceText,
|
|
182
|
+
ref: replaceTextfieldRef,
|
|
183
|
+
autoComplete: "off",
|
|
184
|
+
onChange: handleReplaceChange,
|
|
185
|
+
onKeyDown: handleReplaceKeyDown,
|
|
186
|
+
onCompositionStart: handleCompositionStart,
|
|
187
|
+
onCompositionEnd: handleCompositionEnd
|
|
188
|
+
}), isHelperMessageVisible && !findTyped && /*#__PURE__*/React.createElement("div", {
|
|
189
|
+
ref: successReplacementMessageRef
|
|
190
|
+
}, /*#__PURE__*/React.createElement(ValidMessage, {
|
|
191
|
+
testId: "message-success-replacement"
|
|
192
|
+
}, fakeSuccessReplacementMessageUpdate ?
|
|
193
|
+
// @ts-ignore - TS1501 TypeScript 5.9.2 upgrade
|
|
194
|
+
resultsReplace.replace(/ /u, '\u00a0') : resultsReplace)), /*#__PURE__*/React.createElement(Box, {
|
|
195
|
+
xcss: actionButtonContainerStyles
|
|
196
|
+
}, /*#__PURE__*/React.createElement(Inline, {
|
|
197
|
+
xcss: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? [actionButtonInlineStyles, actionButtonParentInlineStylesNew] : [actionButtonInlineStyles, actionButtonParentInlineStyles]
|
|
198
|
+
}, /*#__PURE__*/React.createElement(Inline, {
|
|
199
|
+
xcss: actionButtonInlineStyles
|
|
200
|
+
}, /*#__PURE__*/React.createElement(FindReplaceTooltipButton, {
|
|
201
|
+
title: formatMessage(messages.findNext),
|
|
202
|
+
icon: iconProps => /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
203
|
+
label: iconProps.label,
|
|
204
|
+
size: "small"
|
|
205
|
+
}),
|
|
206
|
+
iconLabel: formatMessage(messages.findNext),
|
|
207
|
+
keymapDescription: 'Enter',
|
|
208
|
+
onClick: handleFindNextClick,
|
|
209
|
+
disabled: count.total <= 1
|
|
210
|
+
}), /*#__PURE__*/React.createElement(FindReplaceTooltipButton, {
|
|
211
|
+
title: findPrevious,
|
|
212
|
+
icon: iconProps => /*#__PURE__*/React.createElement(ChevronUpIcon, {
|
|
213
|
+
label: iconProps.label,
|
|
214
|
+
size: "small"
|
|
215
|
+
}),
|
|
216
|
+
iconLabel: findPrevious,
|
|
217
|
+
keymapDescription: 'Shift Enter',
|
|
218
|
+
onClick: handleFindPrevClick,
|
|
219
|
+
disabled: count.total <= 1
|
|
220
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
221
|
+
testId: 'Replace',
|
|
222
|
+
id: "replace-button",
|
|
223
|
+
onClick: handleReplaceClick,
|
|
224
|
+
isDisabled: !canReplace
|
|
225
|
+
}, formatMessage(messages.replace)), /*#__PURE__*/React.createElement(Button, {
|
|
226
|
+
appearance: "primary",
|
|
227
|
+
testId: replaceAll,
|
|
228
|
+
id: "replaceAll-button",
|
|
229
|
+
onClick: handleReplaceAllClick,
|
|
230
|
+
isDisabled: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
|
|
231
|
+
}, replaceAll)), expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? /*#__PURE__*/React.createElement(Inline, {
|
|
232
|
+
xcss: closeButtonInlineStyles
|
|
233
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
234
|
+
appearance: "subtle",
|
|
235
|
+
testId: closeFindReplaceDialog,
|
|
236
|
+
onClick: clearSearch
|
|
237
|
+
}, closeFindReplaceDialog)) : /*#__PURE__*/React.createElement(Button, {
|
|
238
|
+
appearance: "subtle",
|
|
239
|
+
testId: closeFindReplaceDialog,
|
|
240
|
+
onClick: clearSearch
|
|
241
|
+
}, closeFindReplaceDialog))));
|
|
242
|
+
};
|
|
332
243
|
export default injectIntl(Replace);
|