@atlaskit/editor-plugin-find-replace 1.2.10 → 1.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 +18 -0
- package/dist/cjs/styles.js +2 -8
- package/dist/cjs/ui/Find.js +29 -80
- package/dist/cjs/ui/FindReplace.js +50 -54
- package/dist/cjs/ui/FindReplaceToolbarButton.js +8 -11
- package/dist/cjs/ui/Replace.js +15 -39
- package/dist/cjs/ui/styles.js +43 -0
- package/dist/es2019/styles.js +3 -9
- package/dist/es2019/ui/Find.js +31 -80
- package/dist/es2019/ui/FindReplace.js +51 -53
- package/dist/es2019/ui/FindReplaceToolbarButton.js +9 -11
- package/dist/es2019/ui/Replace.js +16 -38
- package/dist/es2019/ui/styles.js +43 -0
- package/dist/esm/styles.js +3 -9
- package/dist/esm/ui/Find.js +31 -80
- package/dist/esm/ui/FindReplace.js +51 -53
- package/dist/esm/ui/FindReplaceToolbarButton.js +9 -11
- package/dist/esm/ui/Replace.js +16 -38
- package/dist/esm/ui/styles.js +43 -0
- package/package.json +107 -114
package/dist/cjs/ui/styles.js
CHANGED
|
@@ -11,9 +11,12 @@ var _constants = require("@atlaskit/theme/constants");
|
|
|
11
11
|
/* eslint-disable @atlaskit/design-system/no-nested-styles */
|
|
12
12
|
/* eslint-disable @repo/internal/styles/no-exported-styles */
|
|
13
13
|
/** @jsx jsx */
|
|
14
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
14
15
|
|
|
15
16
|
var fontSize = (0, _constants.fontSize)();
|
|
16
17
|
var gridSize = (0, _constants.gridSize)();
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
17
20
|
var ruleStyles = exports.ruleStyles = (0, _react.css)({
|
|
18
21
|
width: '100%',
|
|
19
22
|
border: 'none',
|
|
@@ -22,67 +25,99 @@ var ruleStyles = exports.ruleStyles = (0, _react.css)({
|
|
|
22
25
|
height: '1px',
|
|
23
26
|
borderRadius: '1px'
|
|
24
27
|
});
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
25
30
|
var wrapperStyles = exports.wrapperStyles = (0, _react.css)({
|
|
26
31
|
display: 'flex',
|
|
27
32
|
flexDirection: 'column',
|
|
33
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
28
34
|
'> *:not(#replace-hr-element)': {
|
|
29
35
|
margin: "0px ".concat("var(--ds-space-050, 4px)")
|
|
30
36
|
}
|
|
31
37
|
});
|
|
38
|
+
|
|
39
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
32
40
|
var wrapperPaddingStyles = exports.wrapperPaddingStyles = (0, _react.css)({
|
|
33
41
|
padding: "var(--ds-space-050, 4px)".concat(" ", "var(--ds-space-050, 4px)")
|
|
34
42
|
});
|
|
43
|
+
|
|
44
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
35
45
|
var sectionWrapperStyles = exports.sectionWrapperStyles = (0, _react.css)({
|
|
36
46
|
display: 'flex',
|
|
47
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
37
48
|
'& > *': {
|
|
38
49
|
display: 'inline-flex',
|
|
39
50
|
height: '32px',
|
|
40
51
|
flex: '0 0 auto'
|
|
41
52
|
},
|
|
53
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
42
54
|
'& > [data-ds--text-field--container]': {
|
|
43
55
|
display: 'flex',
|
|
44
56
|
flex: '1 1 auto'
|
|
45
57
|
}
|
|
46
58
|
});
|
|
59
|
+
|
|
60
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
47
61
|
var sectionWrapperStylesAlternate = exports.sectionWrapperStylesAlternate = (0, _react.css)({
|
|
48
62
|
display: 'flex',
|
|
49
63
|
padding: "var(--ds-space-100, 8px)",
|
|
64
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
50
65
|
'& > *': {
|
|
51
66
|
height: 'unset'
|
|
52
67
|
}
|
|
53
68
|
});
|
|
69
|
+
|
|
70
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
54
71
|
var sectionWrapperJustified = exports.sectionWrapperJustified = (0, _react.css)({
|
|
55
72
|
justifyContent: 'space-between',
|
|
73
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
56
74
|
fontSize: (0, _editorSharedStyles.relativeFontSizeToBase16)(14)
|
|
57
75
|
});
|
|
76
|
+
|
|
77
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
58
78
|
var textFieldWrapper = exports.textFieldWrapper = (0, _react.css)({
|
|
59
79
|
flex: '1 100%',
|
|
60
80
|
flexWrap: 'wrap',
|
|
81
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
61
82
|
'#find-text-field, #replace-text-field': {
|
|
83
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
62
84
|
height: "".concat(gridSize * 4.5 / fontSize, "em")
|
|
63
85
|
},
|
|
86
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
64
87
|
label: {
|
|
88
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
65
89
|
fontSize: (0, _editorSharedStyles.relativeFontSizeToBase16)(14),
|
|
90
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
66
91
|
lineHeight: "".concat(gridSize * 2, "px")
|
|
67
92
|
}
|
|
68
93
|
});
|
|
94
|
+
|
|
95
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
69
96
|
var afterInputSection = exports.afterInputSection = (0, _react.css)({
|
|
70
97
|
display: 'flex',
|
|
71
98
|
flex: '0 0 auto',
|
|
72
99
|
alignItems: 'center'
|
|
73
100
|
});
|
|
101
|
+
|
|
102
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
74
103
|
var matchCaseSection = exports.matchCaseSection = (0, _react.css)({
|
|
75
104
|
paddingRight: "var(--ds-space-100, 8px)",
|
|
105
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
76
106
|
button: {
|
|
77
107
|
width: '20px',
|
|
78
108
|
height: '20px'
|
|
79
109
|
}
|
|
80
110
|
});
|
|
111
|
+
|
|
112
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
81
113
|
var nextPreviousItemStyles = exports.nextPreviousItemStyles = (0, _react.css)({
|
|
82
114
|
padding: "0px ".concat("var(--ds-space-025, 2px)")
|
|
83
115
|
});
|
|
116
|
+
|
|
117
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
84
118
|
var countStyles = exports.countStyles = (0, _react.css)({
|
|
85
119
|
color: "var(--ds-text-subtlest, #626F86)",
|
|
120
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
86
121
|
fontSize: "".concat((0, _editorSharedStyles.relativeFontSizeToBase16)(12)),
|
|
87
122
|
flex: '0 0 auto',
|
|
88
123
|
justifyContent: 'center',
|
|
@@ -90,17 +125,25 @@ var countStyles = exports.countStyles = (0, _react.css)({
|
|
|
90
125
|
marginLeft: "var(--ds-space-050, 4px)",
|
|
91
126
|
marginRight: "var(--ds-space-100, 8px)"
|
|
92
127
|
});
|
|
128
|
+
|
|
129
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
93
130
|
var countStylesAlternateStyles = exports.countStylesAlternateStyles = (0, _react.css)({
|
|
94
131
|
display: 'inline-flex',
|
|
95
132
|
height: '32px'
|
|
96
133
|
});
|
|
134
|
+
|
|
135
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
97
136
|
var countWrapperStyles = exports.countWrapperStyles = (0, _react.css)({
|
|
98
137
|
alignItems: 'center'
|
|
99
138
|
});
|
|
139
|
+
|
|
140
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
100
141
|
var orderZeroStyles = exports.orderZeroStyles = (0, _react.css)({
|
|
101
142
|
order: '0',
|
|
102
143
|
marginInline: "var(--ds-space-050, 4px)".concat(" ", "var(--ds-space-025, 2px)")
|
|
103
144
|
});
|
|
145
|
+
|
|
146
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/design-system/no-exported-css -- Ignored via go/DSP-18766
|
|
104
147
|
var orderOneStyles = exports.orderOneStyles = (0, _react.css)({
|
|
105
148
|
order: '1'
|
|
106
149
|
});
|
package/dist/es2019/styles.js
CHANGED
|
@@ -4,22 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
// TODO: https://product-fabric.atlassian.net/browse/DSP-4290
|
|
6
6
|
import { css } from '@emotion/react';
|
|
7
|
-
import {
|
|
8
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { N40A, N50A, N60A } from '@atlaskit/theme/colors';
|
|
9
8
|
export const searchMatchClass = 'search-match';
|
|
10
9
|
export const selectedSearchMatchClass = 'selected-search-match';
|
|
11
10
|
export const findReplaceStyles = css({
|
|
12
|
-
[`.${searchMatchClass}`]:
|
|
11
|
+
[`.${searchMatchClass}`]: {
|
|
13
12
|
borderRadius: '3px',
|
|
14
13
|
backgroundColor: "var(--ds-background-accent-teal-subtlest, #E7F9FF)",
|
|
15
14
|
boxShadow: `var(--ds-shadow-raised, ${`0 1px 1px 0 ${N50A}, 0 0 1px 0 ${N60A}`})` + ', inset 0 0 0 1px ' + `var(--ds-border-input, ${`${N40A}`})`
|
|
16
|
-
} : {
|
|
17
|
-
backgroundColor: B75
|
|
18
15
|
},
|
|
19
|
-
[`.${selectedSearchMatchClass}`]:
|
|
16
|
+
[`.${selectedSearchMatchClass}`]: {
|
|
20
17
|
backgroundColor: "var(--ds-background-accent-teal-subtle, #6CC3E0)"
|
|
21
|
-
} : {
|
|
22
|
-
backgroundColor: B200,
|
|
23
|
-
color: 'white'
|
|
24
18
|
}
|
|
25
19
|
});
|
package/dist/es2019/ui/Find.js
CHANGED
|
@@ -2,6 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
/* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import React from 'react';
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
5
7
|
import { jsx } from '@emotion/react';
|
|
6
8
|
import debounce from 'lodash/debounce';
|
|
7
9
|
import rafSchd from 'raf-schd';
|
|
@@ -9,14 +11,10 @@ import { injectIntl } from 'react-intl-next';
|
|
|
9
11
|
import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
10
12
|
import { findReplaceMessages as messages } from '@atlaskit/editor-common/messages';
|
|
11
13
|
import { Label } from '@atlaskit/form';
|
|
12
|
-
import EditorCloseIcon from '@atlaskit/icon/glyph/editor/close';
|
|
13
14
|
import MatchCaseIcon from '@atlaskit/icon/glyph/emoji/keyboard';
|
|
14
|
-
import ChevronDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-down';
|
|
15
|
-
import ChevronUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-up';
|
|
16
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
17
15
|
import Textfield from '@atlaskit/textfield';
|
|
18
16
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
19
|
-
import { afterInputSection, countStyles, countStylesAlternateStyles,
|
|
17
|
+
import { afterInputSection, countStyles, countStylesAlternateStyles, matchCaseSection, sectionWrapperStyles, sectionWrapperStylesAlternate, textFieldWrapper } from './styles';
|
|
20
18
|
export const FIND_DEBOUNCE_MS = 100;
|
|
21
19
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
22
20
|
class Find extends React.Component {
|
|
@@ -129,10 +127,7 @@ class Find extends React.Component {
|
|
|
129
127
|
}
|
|
130
128
|
} = props;
|
|
131
129
|
this.find = formatMessage(messages.find);
|
|
132
|
-
this.closeFindReplaceDialog = formatMessage(messages.closeFindReplaceDialog);
|
|
133
130
|
this.noResultsFound = formatMessage(messages.noResultsFound);
|
|
134
|
-
this.findNext = formatMessage(messages.findNext);
|
|
135
|
-
this.findPrevious = formatMessage(messages.findPrevious);
|
|
136
131
|
this.matchCase = formatMessage(messages.matchCase);
|
|
137
132
|
|
|
138
133
|
// We locally manage the value of the input inside this component in order to support compositions.
|
|
@@ -188,26 +183,31 @@ class Find extends React.Component {
|
|
|
188
183
|
selectedMatchPosition: count.index + 1,
|
|
189
184
|
totalResultsCount: count.total
|
|
190
185
|
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
186
|
+
const elemAfterInput =
|
|
187
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
188
|
+
jsx("div", {
|
|
189
|
+
css: afterInputSection
|
|
190
|
+
}, jsx("div", {
|
|
191
|
+
"aria-live": "polite"
|
|
192
|
+
}, findText &&
|
|
193
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
194
|
+
jsx("span", {
|
|
195
|
+
"data-testid": "textfield-count",
|
|
196
|
+
css: [countStyles, countStylesAlternateStyles]
|
|
197
|
+
}, count.total === 0 ? this.noResultsFound : resultsCount)), jsx("div", {
|
|
198
|
+
css: matchCaseSection
|
|
199
|
+
}, jsx(FindReplaceTooltipButton, {
|
|
200
|
+
title: this.matchCase,
|
|
201
|
+
appearance: "default",
|
|
202
|
+
icon: MatchCaseIcon,
|
|
203
|
+
iconLabel: this.matchCase,
|
|
204
|
+
iconSize: 'small',
|
|
205
|
+
onClick: this.handleMatchCaseClick,
|
|
206
|
+
isPressed: shouldMatchCase
|
|
207
|
+
})));
|
|
208
|
+
return (
|
|
209
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
210
|
+
jsx("div", {
|
|
211
211
|
css: [sectionWrapperStyles, sectionWrapperStylesAlternate]
|
|
212
212
|
}, jsx("div", {
|
|
213
213
|
css: textFieldWrapper
|
|
@@ -216,6 +216,7 @@ class Find extends React.Component {
|
|
|
216
216
|
}, this.find), jsx(Textfield, {
|
|
217
217
|
name: "find",
|
|
218
218
|
id: "find-text-field",
|
|
219
|
+
testId: "find-field",
|
|
219
220
|
appearance: "standard",
|
|
220
221
|
value: this.state.localFindText,
|
|
221
222
|
ref: this.findTextfieldRef,
|
|
@@ -227,58 +228,8 @@ class Find extends React.Component {
|
|
|
227
228
|
onCompositionStart: this.handleCompositionStart,
|
|
228
229
|
onCompositionEnd: this.handleCompositionEnd,
|
|
229
230
|
elemAfterInput: elemAfterInput
|
|
230
|
-
})))
|
|
231
|
-
|
|
232
|
-
return jsx("div", {
|
|
233
|
-
css: sectionWrapperStyles
|
|
234
|
-
}, jsx(Textfield, {
|
|
235
|
-
name: "find",
|
|
236
|
-
appearance: "none",
|
|
237
|
-
placeholder: this.find,
|
|
238
|
-
value: this.state.localFindText,
|
|
239
|
-
ref: this.findTextfieldRef,
|
|
240
|
-
autoComplete: "off",
|
|
241
|
-
onChange: this.handleFindChange,
|
|
242
|
-
onKeyDown: this.handleFindKeyDown,
|
|
243
|
-
onKeyUp: this.handleFindKeyUp,
|
|
244
|
-
onBlur: this.props.onFindBlur,
|
|
245
|
-
onCompositionStart: this.handleCompositionStart,
|
|
246
|
-
onCompositionEnd: this.handleCompositionEnd
|
|
247
|
-
}), jsx("div", {
|
|
248
|
-
css: countWrapperStyles,
|
|
249
|
-
"aria-live": "polite"
|
|
250
|
-
}, findText && jsx("span", {
|
|
251
|
-
"data-testid": "textfield-count",
|
|
252
|
-
css: countStyles
|
|
253
|
-
}, count.total === 0 ? this.noResultsFound : resultsCount)), jsx(FindReplaceTooltipButton, {
|
|
254
|
-
title: this.matchCase,
|
|
255
|
-
icon: MatchCaseIcon,
|
|
256
|
-
iconLabel: this.matchCase,
|
|
257
|
-
iconSize: getBooleanFF('platform.editor.a11y-find-replace') ? 'small' : undefined,
|
|
258
|
-
onClick: this.handleMatchCaseClick,
|
|
259
|
-
isPressed: shouldMatchCase
|
|
260
|
-
}), jsx(FindReplaceTooltipButton, {
|
|
261
|
-
title: this.findNext,
|
|
262
|
-
icon: ChevronDownIcon,
|
|
263
|
-
iconLabel: this.findNext,
|
|
264
|
-
keymapDescription: 'Enter',
|
|
265
|
-
onClick: this.handleFindNextClick,
|
|
266
|
-
disabled: count.total <= 1
|
|
267
|
-
}), jsx(FindReplaceTooltipButton, {
|
|
268
|
-
title: this.findPrevious,
|
|
269
|
-
icon: ChevronUpIcon,
|
|
270
|
-
iconLabel: this.findPrevious,
|
|
271
|
-
keymapDescription: 'Shift Enter',
|
|
272
|
-
onClick: this.handleFindPrevClick,
|
|
273
|
-
disabled: count.total <= 1
|
|
274
|
-
}), jsx(FindReplaceTooltipButton, {
|
|
275
|
-
title: this.closeFindReplaceDialog,
|
|
276
|
-
icon: EditorCloseIcon,
|
|
277
|
-
iconLabel: this.closeFindReplaceDialog,
|
|
278
|
-
keymapDescription: 'Escape',
|
|
279
|
-
onClick: this.clearSearch
|
|
280
|
-
}));
|
|
281
|
-
}
|
|
231
|
+
})))
|
|
232
|
+
);
|
|
282
233
|
}
|
|
283
234
|
}
|
|
284
235
|
export default injectIntl(Find);
|
|
@@ -3,8 +3,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
4
4
|
/** @jsx jsx */
|
|
5
5
|
import React from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
8
|
import { jsx } from '@emotion/react';
|
|
7
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import Find from './Find';
|
|
9
10
|
import Replace from './Replace';
|
|
10
11
|
import { ruleStyles, wrapperPaddingStyles, wrapperStyles } from './styles';
|
|
@@ -37,11 +38,9 @@ class FindReplace extends React.PureComponent {
|
|
|
37
38
|
findTyped: false
|
|
38
39
|
});
|
|
39
40
|
_defineProperty(this, "setFindTyped", value => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
}
|
|
41
|
+
this.setState({
|
|
42
|
+
findTyped: value
|
|
43
|
+
});
|
|
45
44
|
});
|
|
46
45
|
_defineProperty(this, "setFindTextfieldRef", findTextfieldRef => {
|
|
47
46
|
this.findTextfield = findTextfieldRef.current;
|
|
@@ -62,16 +61,12 @@ class FindReplace extends React.PureComponent {
|
|
|
62
61
|
this.modalRef = /*#__PURE__*/React.createRef();
|
|
63
62
|
}
|
|
64
63
|
componentDidMount() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
window.addEventListener('keydown', this.handleTabNavigation);
|
|
68
|
-
}
|
|
64
|
+
// eslint-disable-next-line
|
|
65
|
+
window.addEventListener('keydown', this.handleTabNavigation);
|
|
69
66
|
}
|
|
70
67
|
componentWillUnmount() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
window.removeEventListener('keydown', this.handleTabNavigation);
|
|
74
|
-
}
|
|
68
|
+
// eslint-disable-next-line
|
|
69
|
+
window.removeEventListener('keydown', this.handleTabNavigation);
|
|
75
70
|
}
|
|
76
71
|
render() {
|
|
77
72
|
const {
|
|
@@ -91,45 +86,48 @@ class FindReplace extends React.PureComponent {
|
|
|
91
86
|
shouldMatchCase,
|
|
92
87
|
onToggleMatchCase
|
|
93
88
|
} = this.props;
|
|
94
|
-
const focusToolbarButton =
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
89
|
+
const focusToolbarButton = this.props.focusToolbarButton || (() => {});
|
|
90
|
+
return (
|
|
91
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
92
|
+
jsx("div", {
|
|
93
|
+
ref: this.modalRef,
|
|
94
|
+
css: [wrapperStyles, wrapperPaddingStyles]
|
|
95
|
+
}, jsx(Find, {
|
|
96
|
+
allowMatchCase: allowMatchCase,
|
|
97
|
+
shouldMatchCase: shouldMatchCase,
|
|
98
|
+
onToggleMatchCase: onToggleMatchCase,
|
|
99
|
+
findText: findText,
|
|
100
|
+
count: count,
|
|
101
|
+
shouldFocus: shouldFocus,
|
|
102
|
+
onFind: onFind,
|
|
103
|
+
onFindBlur: onFindBlur,
|
|
104
|
+
onFindPrev: onFindPrev,
|
|
105
|
+
onFindNext: onFindNext,
|
|
106
|
+
onFindTextfieldRefSet: this.setFindTextfieldRef,
|
|
107
|
+
onCancel: onCancel,
|
|
108
|
+
onArrowDown: this.setFocusToReplace,
|
|
109
|
+
findTyped: this.state.findTyped,
|
|
110
|
+
setFindTyped: this.setFindTyped
|
|
111
|
+
}), jsx("hr", {
|
|
112
|
+
css: ruleStyles,
|
|
113
|
+
id: "replace-hr-element"
|
|
114
|
+
}), jsx(Replace, {
|
|
115
|
+
canReplace: count.total > 0,
|
|
116
|
+
replaceText: replaceText,
|
|
117
|
+
onReplace: onReplace,
|
|
118
|
+
onReplaceAll: onReplaceAll,
|
|
119
|
+
onReplaceTextfieldRefSet: this.setReplaceTextfieldRef,
|
|
120
|
+
onArrowUp: this.setFocusToFind,
|
|
121
|
+
onCancel: onCancel,
|
|
122
|
+
count: count,
|
|
123
|
+
onFindPrev: onFindPrev,
|
|
124
|
+
onFindNext: onFindNext,
|
|
125
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
126
|
+
findTyped: this.state.findTyped,
|
|
127
|
+
setFindTyped: this.setFindTyped,
|
|
128
|
+
focusToolbarButton: focusToolbarButton
|
|
129
|
+
}))
|
|
130
|
+
);
|
|
133
131
|
}
|
|
134
132
|
}
|
|
135
133
|
export default FindReplace;
|
|
@@ -3,6 +3,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
/* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
|
|
4
4
|
/** @jsx jsx */
|
|
5
5
|
import React from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
8
|
import { css, jsx } from '@emotion/react';
|
|
7
9
|
import { injectIntl } from 'react-intl-next';
|
|
8
10
|
import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
@@ -11,7 +13,6 @@ import { findReplaceMessages as messages } from '@atlaskit/editor-common/message
|
|
|
11
13
|
import { ArrowKeyNavigationType, Dropdown, TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
12
14
|
import { akEditorFloatingPanelZIndex, akEditorMobileMaxWidth } from '@atlaskit/editor-shared-styles';
|
|
13
15
|
import EditorSearchIcon from '@atlaskit/icon/glyph/editor/search';
|
|
14
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
15
16
|
import FindReplace from './FindReplace';
|
|
16
17
|
|
|
17
18
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- needs manual remediation
|
|
@@ -35,7 +36,6 @@ const wrapper = css({
|
|
|
35
36
|
flexDirection: 'column'
|
|
36
37
|
});
|
|
37
38
|
const dropdownWidthNewDesign = 382;
|
|
38
|
-
const dropdownWidthOldDesign = 352;
|
|
39
39
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
40
40
|
class FindReplaceToolbarButton extends React.PureComponent {
|
|
41
41
|
constructor(...args) {
|
|
@@ -96,17 +96,15 @@ class FindReplaceToolbarButton extends React.PureComponent {
|
|
|
96
96
|
this.props.onCancel({
|
|
97
97
|
triggerMethod: TRIGGER_METHOD.KEYBOARD
|
|
98
98
|
});
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
this.toolbarButtonRef.current.focus();
|
|
102
|
-
}
|
|
103
|
-
this.setState({
|
|
104
|
-
openedByClick: false
|
|
105
|
-
});
|
|
99
|
+
if (this.state.openedByClick && this.toolbarButtonRef.current) {
|
|
100
|
+
this.toolbarButtonRef.current.focus();
|
|
106
101
|
}
|
|
102
|
+
this.setState({
|
|
103
|
+
openedByClick: false
|
|
104
|
+
});
|
|
107
105
|
}
|
|
108
106
|
},
|
|
109
|
-
fitWidth:
|
|
107
|
+
fitWidth: dropdownWidthNewDesign,
|
|
110
108
|
zIndex: stackBelowOtherEditorFloatingPanels,
|
|
111
109
|
arrowKeyNavigationProviderOptions: {
|
|
112
110
|
type: ArrowKeyNavigationType.MENU,
|
|
@@ -128,7 +126,7 @@ class FindReplaceToolbarButton extends React.PureComponent {
|
|
|
128
126
|
"aria-haspopup": true,
|
|
129
127
|
"aria-label": keymap ? tooltip(keymap, title) : title,
|
|
130
128
|
"aria-keyshortcuts": getAriaKeyshortcuts(keymap),
|
|
131
|
-
ref:
|
|
129
|
+
ref: this.toolbarButtonRef
|
|
132
130
|
})
|
|
133
131
|
}, jsx("div", {
|
|
134
132
|
css: wrapper
|
|
@@ -2,6 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
/* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import React, { Fragment } from 'react';
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
5
7
|
import { jsx } from '@emotion/react';
|
|
6
8
|
import { injectIntl } from 'react-intl-next';
|
|
7
9
|
import Button from '@atlaskit/button/new';
|
|
@@ -10,7 +12,6 @@ import { findReplaceMessages as messages } from '@atlaskit/editor-common/message
|
|
|
10
12
|
import { Label, ValidMessage } from '@atlaskit/form';
|
|
11
13
|
import ChevronDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-down';
|
|
12
14
|
import ChevronUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-up';
|
|
13
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
14
15
|
import { Inline, xcss } from '@atlaskit/primitives';
|
|
15
16
|
import Textfield from '@atlaskit/textfield';
|
|
16
17
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
@@ -131,7 +132,6 @@ class Replace extends React.PureComponent {
|
|
|
131
132
|
fakeSuccessReplacementMessageUpdate: false,
|
|
132
133
|
replaceCount: 0
|
|
133
134
|
};
|
|
134
|
-
this.replaceWith = formatMessage(messages.replaceWith);
|
|
135
135
|
this.replace = formatMessage(messages.replace);
|
|
136
136
|
this.replaceAll = formatMessage(messages.replaceAll);
|
|
137
137
|
this.findNext = formatMessage(messages.findNext);
|
|
@@ -153,13 +153,11 @@ class Replace extends React.PureComponent {
|
|
|
153
153
|
isComposing: false
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
findTextField.focus();
|
|
162
|
-
}
|
|
156
|
+
const findTextField = document.getElementById('find-text-field');
|
|
157
|
+
const replaceButton = document.getElementById('replace-button');
|
|
158
|
+
const replaceAllButton = document.getElementById('replaceAll-button');
|
|
159
|
+
if (((replaceButton === null || replaceButton === void 0 ? void 0 : replaceButton.tabIndex) === -1 || (replaceAllButton === null || replaceAllButton === void 0 ? void 0 : replaceAllButton.tabIndex) === -1) && findTextField) {
|
|
160
|
+
findTextField.focus();
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
163
|
triggerSuccessReplacementMessageUpdate(currentReplaceCount) {
|
|
@@ -191,7 +189,7 @@ class Replace extends React.PureComponent {
|
|
|
191
189
|
const resultsReplace = formatMessage(messages.replaceSuccess, {
|
|
192
190
|
numberOfMatches: replaceCount
|
|
193
191
|
});
|
|
194
|
-
return
|
|
192
|
+
return jsx(Fragment, null, jsx("div", {
|
|
195
193
|
css: [sectionWrapperStyles, sectionWrapperStylesAlternate]
|
|
196
194
|
}, jsx("div", {
|
|
197
195
|
css: textFieldWrapper
|
|
@@ -200,6 +198,7 @@ class Replace extends React.PureComponent {
|
|
|
200
198
|
}, "Replace with"), jsx(Textfield, {
|
|
201
199
|
name: "replace",
|
|
202
200
|
id: "replace-text-field",
|
|
201
|
+
testId: "replace-field",
|
|
203
202
|
appearance: "standard",
|
|
204
203
|
defaultValue: replaceText,
|
|
205
204
|
ref: this.replaceTextfieldRef,
|
|
@@ -214,9 +213,9 @@ class Replace extends React.PureComponent {
|
|
|
214
213
|
testId: "message-success-replacement"
|
|
215
214
|
},
|
|
216
215
|
/*
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
216
|
+
Replacement needed to trigger the SR announcement if message hasn't changed. e.g Replace button clicked twice.
|
|
217
|
+
'\u00a0' is value for  
|
|
218
|
+
*/
|
|
220
219
|
this.state.fakeSuccessReplacementMessageUpdate ? resultsReplace.replace(/ /, '\u00a0') : resultsReplace)))), jsx("div", {
|
|
221
220
|
css: [sectionWrapperStyles, sectionWrapperStylesAlternate, sectionWrapperJustified]
|
|
222
221
|
}, jsx("div", {
|
|
@@ -240,7 +239,9 @@ class Replace extends React.PureComponent {
|
|
|
240
239
|
onClick: this.handleFindPrevClick,
|
|
241
240
|
disabled: count.total <= 1
|
|
242
241
|
})), jsx(Inline, {
|
|
243
|
-
space: "space.075"
|
|
242
|
+
space: "space.075"
|
|
243
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
244
|
+
,
|
|
244
245
|
xcss: xcss({
|
|
245
246
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
246
247
|
paddingInlineStart: 'space.050',
|
|
@@ -264,30 +265,7 @@ class Replace extends React.PureComponent {
|
|
|
264
265
|
appearance: "subtle",
|
|
265
266
|
testId: this.closeFindReplaceDialog,
|
|
266
267
|
onClick: this.clearSearch
|
|
267
|
-
}, this.closeFindReplaceDialog))))
|
|
268
|
-
css: sectionWrapperStyles
|
|
269
|
-
}, jsx(Textfield, {
|
|
270
|
-
name: "replace",
|
|
271
|
-
appearance: "none",
|
|
272
|
-
placeholder: this.replaceWith,
|
|
273
|
-
defaultValue: replaceText,
|
|
274
|
-
ref: this.replaceTextfieldRef,
|
|
275
|
-
autoComplete: "off",
|
|
276
|
-
onChange: this.handleReplaceChange,
|
|
277
|
-
onKeyDown: this.handleReplaceKeyDown,
|
|
278
|
-
onCompositionStart: this.handleCompositionStart,
|
|
279
|
-
onCompositionEnd: this.handleCompositionEnd
|
|
280
|
-
}), jsx(Inline, {
|
|
281
|
-
space: "space.050"
|
|
282
|
-
}, jsx(Button, {
|
|
283
|
-
testId: this.replace,
|
|
284
|
-
onClick: this.handleReplaceClick,
|
|
285
|
-
isDisabled: !canReplace
|
|
286
|
-
}, this.replace), jsx(Button, {
|
|
287
|
-
testId: this.replaceAll,
|
|
288
|
-
onClick: this.handleReplaceAllClick,
|
|
289
|
-
isDisabled: !canReplace
|
|
290
|
-
}, this.replaceAll)));
|
|
268
|
+
}, this.closeFindReplaceDialog))));
|
|
291
269
|
}
|
|
292
270
|
}
|
|
293
271
|
export default injectIntl(Replace);
|