@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
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { useState, useRef, useEffect } from 'react';
|
|
3
|
-
import { injectIntl } from 'react-intl-next';
|
|
4
|
-
import Button from '@atlaskit/button/new';
|
|
5
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
import { findReplaceMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
|
-
import { ValidMessage } from '@atlaskit/form';
|
|
8
|
-
import ChevronDownIcon from '@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down';
|
|
9
|
-
import ChevronUpIcon from '@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up';
|
|
10
|
-
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
11
|
-
import { Box, Inline, Text, xcss } from '@atlaskit/primitives';
|
|
12
|
-
import Textfield from '@atlaskit/textfield';
|
|
13
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
|
-
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
15
|
-
var replaceContainerStyles = xcss({
|
|
16
|
-
padding: 'space.100'
|
|
17
|
-
});
|
|
18
|
-
var replaceWithLabelStyle = xcss({
|
|
19
|
-
paddingBottom: 'space.050'
|
|
20
|
-
});
|
|
21
|
-
var actionButtonContainerStyles = xcss({
|
|
22
|
-
paddingTop: 'space.200'
|
|
23
|
-
});
|
|
24
|
-
var actionButtonParentInlineStyles = xcss({
|
|
25
|
-
justifyContent: 'space-between',
|
|
26
|
-
flexDirection: 'row-reverse'
|
|
27
|
-
});
|
|
28
|
-
var actionButtonParentInlineStylesNew = xcss({
|
|
29
|
-
justifyContent: 'space-between',
|
|
30
|
-
flexDirection: 'row-reverse',
|
|
31
|
-
flexWrap: 'wrap'
|
|
32
|
-
});
|
|
33
|
-
var actionButtonInlineStyles = xcss({
|
|
34
|
-
gap: 'space.075'
|
|
35
|
-
});
|
|
36
|
-
var closeButtonInlineStyles = xcss({
|
|
37
|
-
marginRight: 'auto'
|
|
38
|
-
});
|
|
39
|
-
var Replace = function Replace(_ref) {
|
|
40
|
-
var canReplace = _ref.canReplace,
|
|
41
|
-
initialReplaceText = _ref.replaceText,
|
|
42
|
-
onReplace = _ref.onReplace,
|
|
43
|
-
onReplaceAll = _ref.onReplaceAll,
|
|
44
|
-
onReplaceTextfieldRefSet = _ref.onReplaceTextfieldRefSet,
|
|
45
|
-
onArrowUp = _ref.onArrowUp,
|
|
46
|
-
onCancel = _ref.onCancel,
|
|
47
|
-
count = _ref.count,
|
|
48
|
-
onFindNext = _ref.onFindNext,
|
|
49
|
-
onFindPrev = _ref.onFindPrev,
|
|
50
|
-
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
51
|
-
setFindTyped = _ref.setFindTyped,
|
|
52
|
-
findTyped = _ref.findTyped,
|
|
53
|
-
focusToolbarButton = _ref.focusToolbarButton,
|
|
54
|
-
formatMessage = _ref.intl.formatMessage;
|
|
55
|
-
var _useState = useState(initialReplaceText || ''),
|
|
56
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
57
|
-
replaceText = _useState2[0],
|
|
58
|
-
setReplaceText = _useState2[1];
|
|
59
|
-
var _useState3 = useState(false),
|
|
60
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
61
|
-
isComposing = _useState4[0],
|
|
62
|
-
setIsComposing = _useState4[1];
|
|
63
|
-
var _useState5 = useState(false),
|
|
64
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
65
|
-
isHelperMessageVisible = _useState6[0],
|
|
66
|
-
setIsHelperMessageVisible = _useState6[1];
|
|
67
|
-
var _useState7 = useState(false),
|
|
68
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
69
|
-
fakeSuccessReplacementMessageUpdate = _useState8[0],
|
|
70
|
-
setFakeSuccessReplacementMessageUpdate = _useState8[1];
|
|
71
|
-
var _useState9 = useState(0),
|
|
72
|
-
_useState0 = _slicedToArray(_useState9, 2),
|
|
73
|
-
replaceCount = _useState0[0],
|
|
74
|
-
setReplaceCount = _useState0[1];
|
|
75
|
-
var replaceTextfieldRef = useRef(null);
|
|
76
|
-
var successReplacementMessageRef = useRef(null);
|
|
77
|
-
var replaceWith = formatMessage(messages.replaceWith);
|
|
78
|
-
var replaceAll = formatMessage(messages.replaceAll);
|
|
79
|
-
var findPrevious = formatMessage(messages.findPrevious);
|
|
80
|
-
var closeFindReplaceDialog = formatMessage(messages.closeFindReplaceDialog);
|
|
81
|
-
useEffect(function () {
|
|
82
|
-
onReplaceTextfieldRefSet(replaceTextfieldRef);
|
|
83
|
-
}, [onReplaceTextfieldRefSet]);
|
|
84
|
-
useEffect(function () {
|
|
85
|
-
setReplaceText(initialReplaceText || '');
|
|
86
|
-
}, [initialReplaceText]);
|
|
87
|
-
var skipWhileComposing = function skipWhileComposing(fn) {
|
|
88
|
-
if (!isComposing) {
|
|
89
|
-
fn();
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
var triggerSuccessReplacementMessageUpdate = function triggerSuccessReplacementMessageUpdate(currentReplaceCount) {
|
|
93
|
-
if (replaceCount === currentReplaceCount) {
|
|
94
|
-
setFakeSuccessReplacementMessageUpdate(!fakeSuccessReplacementMessageUpdate);
|
|
95
|
-
}
|
|
96
|
-
if (successReplacementMessageRef.current) {
|
|
97
|
-
var ariaLiveRegion = successReplacementMessageRef.current.querySelector('[aria-live="polite"]');
|
|
98
|
-
ariaLiveRegion === null || ariaLiveRegion === void 0 || ariaLiveRegion.removeAttribute('aria-live');
|
|
99
|
-
ariaLiveRegion === null || ariaLiveRegion === void 0 || ariaLiveRegion.setAttribute('aria-live', 'polite');
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
var handleReplaceClick = function handleReplaceClick() {
|
|
103
|
-
return skipWhileComposing(function () {
|
|
104
|
-
onReplace({
|
|
105
|
-
triggerMethod: TRIGGER_METHOD.BUTTON,
|
|
106
|
-
replaceText: replaceText
|
|
107
|
-
});
|
|
108
|
-
triggerSuccessReplacementMessageUpdate(1);
|
|
109
|
-
setIsHelperMessageVisible(true);
|
|
110
|
-
setReplaceCount(1);
|
|
111
|
-
setFindTyped(false);
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
var handleReplaceChange = function handleReplaceChange(event) {
|
|
115
|
-
return skipWhileComposing(function () {
|
|
116
|
-
updateReplaceValue(event.target.value);
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
var updateReplaceValue = function updateReplaceValue(text) {
|
|
120
|
-
if (dispatchAnalyticsEvent) {
|
|
121
|
-
dispatchAnalyticsEvent({
|
|
122
|
-
eventType: EVENT_TYPE.TRACK,
|
|
123
|
-
action: ACTION.CHANGED_REPLACEMENT_TEXT,
|
|
124
|
-
actionSubject: ACTION_SUBJECT.FIND_REPLACE_DIALOG
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
setReplaceText(text);
|
|
128
|
-
};
|
|
129
|
-
var handleReplaceKeyDown = function handleReplaceKeyDown(event) {
|
|
130
|
-
return skipWhileComposing(function () {
|
|
131
|
-
if (event.key === 'Enter') {
|
|
132
|
-
onReplace({
|
|
133
|
-
triggerMethod: TRIGGER_METHOD.KEYBOARD,
|
|
134
|
-
replaceText: replaceText
|
|
135
|
-
});
|
|
136
|
-
} else if (event.key === 'ArrowUp') {
|
|
137
|
-
onArrowUp();
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
var handleReplaceAllClick = function handleReplaceAllClick() {
|
|
142
|
-
return skipWhileComposing(function () {
|
|
143
|
-
onReplaceAll({
|
|
144
|
-
replaceText: replaceText
|
|
145
|
-
});
|
|
146
|
-
setIsHelperMessageVisible(true);
|
|
147
|
-
if (count.totalReplaceable && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
148
|
-
triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
|
|
149
|
-
setReplaceCount(count.totalReplaceable);
|
|
150
|
-
} else {
|
|
151
|
-
triggerSuccessReplacementMessageUpdate(count.total);
|
|
152
|
-
setReplaceCount(count.total);
|
|
153
|
-
}
|
|
154
|
-
setFindTyped(false);
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
var handleCompositionStart = function handleCompositionStart() {
|
|
158
|
-
setIsComposing(true);
|
|
159
|
-
};
|
|
160
|
-
var handleCompositionEnd = function handleCompositionEnd(event) {
|
|
161
|
-
setIsComposing(false);
|
|
162
|
-
updateReplaceValue(event.currentTarget.value);
|
|
163
|
-
};
|
|
164
|
-
var clearSearch = function clearSearch() {
|
|
165
|
-
onCancel({
|
|
166
|
-
triggerMethod: TRIGGER_METHOD.BUTTON
|
|
167
|
-
});
|
|
168
|
-
focusToolbarButton();
|
|
169
|
-
};
|
|
170
|
-
var handleFindNextClick = function handleFindNextClick() {
|
|
171
|
-
if (!isComposing) {
|
|
172
|
-
onFindNext({
|
|
173
|
-
triggerMethod: TRIGGER_METHOD.BUTTON
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
var handleFindPrevClick = function handleFindPrevClick() {
|
|
178
|
-
if (!isComposing) {
|
|
179
|
-
onFindPrev({
|
|
180
|
-
triggerMethod: TRIGGER_METHOD.BUTTON
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
var resultsReplace = formatMessage(messages.replaceSuccess, {
|
|
185
|
-
numberOfMatches: replaceCount
|
|
186
|
-
});
|
|
187
|
-
return /*#__PURE__*/React.createElement(Box, {
|
|
188
|
-
xcss: replaceContainerStyles
|
|
189
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
190
|
-
xcss: replaceWithLabelStyle
|
|
191
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
192
|
-
id: "replace-text-field-label",
|
|
193
|
-
size: "medium",
|
|
194
|
-
weight: "bold",
|
|
195
|
-
color: "color.text.subtle"
|
|
196
|
-
}, replaceWith)), /*#__PURE__*/React.createElement(Textfield, {
|
|
197
|
-
name: "replace",
|
|
198
|
-
"aria-labelledby": "replace-text-field-label",
|
|
199
|
-
testId: "replace-field",
|
|
200
|
-
appearance: "standard",
|
|
201
|
-
defaultValue: replaceText,
|
|
202
|
-
ref: replaceTextfieldRef,
|
|
203
|
-
autoComplete: "off",
|
|
204
|
-
onChange: handleReplaceChange,
|
|
205
|
-
onKeyDown: handleReplaceKeyDown,
|
|
206
|
-
onCompositionStart: handleCompositionStart,
|
|
207
|
-
onCompositionEnd: handleCompositionEnd
|
|
208
|
-
}), isHelperMessageVisible && !findTyped && /*#__PURE__*/React.createElement("div", {
|
|
209
|
-
ref: successReplacementMessageRef
|
|
210
|
-
}, /*#__PURE__*/React.createElement(ValidMessage, {
|
|
211
|
-
testId: "message-success-replacement"
|
|
212
|
-
}, fakeSuccessReplacementMessageUpdate ?
|
|
213
|
-
// @ts-ignore - TS1501 TypeScript 5.9.2 upgrade
|
|
214
|
-
resultsReplace.replace(/ /, "\xA0") : resultsReplace)), /*#__PURE__*/React.createElement(Box, {
|
|
215
|
-
xcss: actionButtonContainerStyles
|
|
216
|
-
}, /*#__PURE__*/React.createElement(Inline, {
|
|
217
|
-
xcss: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? [actionButtonInlineStyles, actionButtonParentInlineStylesNew] : [actionButtonInlineStyles, actionButtonParentInlineStyles]
|
|
218
|
-
}, /*#__PURE__*/React.createElement(Inline, {
|
|
219
|
-
xcss: actionButtonInlineStyles
|
|
220
|
-
}, /*#__PURE__*/React.createElement(FindReplaceTooltipButton, {
|
|
221
|
-
title: formatMessage(messages.findNext),
|
|
222
|
-
icon: function icon(iconProps) {
|
|
223
|
-
return /*#__PURE__*/React.createElement(ChevronDownIcon, {
|
|
224
|
-
label: iconProps.label,
|
|
225
|
-
size: "small"
|
|
226
|
-
});
|
|
227
|
-
},
|
|
228
|
-
iconLabel: formatMessage(messages.findNext),
|
|
229
|
-
keymapDescription: 'Enter',
|
|
230
|
-
onClick: handleFindNextClick,
|
|
231
|
-
disabled: count.total <= 1
|
|
232
|
-
}), /*#__PURE__*/React.createElement(FindReplaceTooltipButton, {
|
|
233
|
-
title: findPrevious,
|
|
234
|
-
icon: function icon(iconProps) {
|
|
235
|
-
return /*#__PURE__*/React.createElement(ChevronUpIcon, {
|
|
236
|
-
label: iconProps.label,
|
|
237
|
-
size: "small"
|
|
238
|
-
});
|
|
239
|
-
},
|
|
240
|
-
iconLabel: findPrevious,
|
|
241
|
-
keymapDescription: 'Shift Enter',
|
|
242
|
-
onClick: handleFindPrevClick,
|
|
243
|
-
disabled: count.total <= 1
|
|
244
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
245
|
-
testId: 'Replace',
|
|
246
|
-
id: "replace-button",
|
|
247
|
-
onClick: handleReplaceClick,
|
|
248
|
-
isDisabled: !canReplace
|
|
249
|
-
}, formatMessage(messages.replace)), /*#__PURE__*/React.createElement(Button, {
|
|
250
|
-
appearance: "primary",
|
|
251
|
-
testId: replaceAll,
|
|
252
|
-
id: "replaceAll-button",
|
|
253
|
-
onClick: handleReplaceAllClick,
|
|
254
|
-
isDisabled: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
|
|
255
|
-
}, replaceAll)), expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? /*#__PURE__*/React.createElement(Inline, {
|
|
256
|
-
xcss: closeButtonInlineStyles
|
|
257
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
258
|
-
appearance: "subtle",
|
|
259
|
-
testId: closeFindReplaceDialog,
|
|
260
|
-
onClick: clearSearch
|
|
261
|
-
}, closeFindReplaceDialog)) : /*#__PURE__*/React.createElement(Button, {
|
|
262
|
-
appearance: "subtle",
|
|
263
|
-
testId: closeFindReplaceDialog,
|
|
264
|
-
onClick: clearSearch
|
|
265
|
-
}, closeFindReplaceDialog))));
|
|
266
|
-
};
|
|
267
|
-
export default injectIntl(Replace);
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
export type ReplaceProps = {
|
|
6
|
-
canReplace: boolean;
|
|
7
|
-
count: {
|
|
8
|
-
index: number;
|
|
9
|
-
total: number;
|
|
10
|
-
totalReplaceable?: number;
|
|
11
|
-
};
|
|
12
|
-
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
13
|
-
findTyped: boolean;
|
|
14
|
-
focusToolbarButton: () => void;
|
|
15
|
-
onArrowUp: () => void;
|
|
16
|
-
onCancel: ({ triggerMethod, }: {
|
|
17
|
-
triggerMethod: TRIGGER_METHOD.KEYBOARD | TRIGGER_METHOD.TOOLBAR | TRIGGER_METHOD.BUTTON;
|
|
18
|
-
}) => void;
|
|
19
|
-
onFindNext: ({ triggerMethod, }: {
|
|
20
|
-
triggerMethod: TRIGGER_METHOD.KEYBOARD | TRIGGER_METHOD.BUTTON;
|
|
21
|
-
}) => void;
|
|
22
|
-
onFindPrev: ({ triggerMethod, }: {
|
|
23
|
-
triggerMethod: TRIGGER_METHOD.KEYBOARD | TRIGGER_METHOD.BUTTON;
|
|
24
|
-
}) => void;
|
|
25
|
-
onReplace: ({ triggerMethod, replaceText, }: {
|
|
26
|
-
replaceText: string;
|
|
27
|
-
triggerMethod: TRIGGER_METHOD.KEYBOARD | TRIGGER_METHOD.BUTTON;
|
|
28
|
-
}) => void;
|
|
29
|
-
onReplaceAll: ({ replaceText }: {
|
|
30
|
-
replaceText: string;
|
|
31
|
-
}) => void;
|
|
32
|
-
onReplaceTextfieldRefSet: (ref: React.RefObject<HTMLInputElement>) => void;
|
|
33
|
-
replaceText?: string;
|
|
34
|
-
setFindTyped: (value: boolean) => void;
|
|
35
|
-
};
|
|
36
|
-
declare const _default: React.FC<import("react-intl-next").WithIntlProps<ReplaceProps & WrappedComponentProps>> & {
|
|
37
|
-
WrappedComponent: React.ComponentType<ReplaceProps & WrappedComponentProps>;
|
|
38
|
-
};
|
|
39
|
-
export default _default;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
export type ReplaceProps = {
|
|
6
|
-
canReplace: boolean;
|
|
7
|
-
count: {
|
|
8
|
-
index: number;
|
|
9
|
-
total: number;
|
|
10
|
-
totalReplaceable?: number;
|
|
11
|
-
};
|
|
12
|
-
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
13
|
-
findTyped: boolean;
|
|
14
|
-
focusToolbarButton: () => void;
|
|
15
|
-
onArrowUp: () => void;
|
|
16
|
-
onCancel: ({ triggerMethod, }: {
|
|
17
|
-
triggerMethod: TRIGGER_METHOD.KEYBOARD | TRIGGER_METHOD.TOOLBAR | TRIGGER_METHOD.BUTTON;
|
|
18
|
-
}) => void;
|
|
19
|
-
onFindNext: ({ triggerMethod, }: {
|
|
20
|
-
triggerMethod: TRIGGER_METHOD.KEYBOARD | TRIGGER_METHOD.BUTTON;
|
|
21
|
-
}) => void;
|
|
22
|
-
onFindPrev: ({ triggerMethod, }: {
|
|
23
|
-
triggerMethod: TRIGGER_METHOD.KEYBOARD | TRIGGER_METHOD.BUTTON;
|
|
24
|
-
}) => void;
|
|
25
|
-
onReplace: ({ triggerMethod, replaceText, }: {
|
|
26
|
-
replaceText: string;
|
|
27
|
-
triggerMethod: TRIGGER_METHOD.KEYBOARD | TRIGGER_METHOD.BUTTON;
|
|
28
|
-
}) => void;
|
|
29
|
-
onReplaceAll: ({ replaceText }: {
|
|
30
|
-
replaceText: string;
|
|
31
|
-
}) => void;
|
|
32
|
-
onReplaceTextfieldRefSet: (ref: React.RefObject<HTMLInputElement>) => void;
|
|
33
|
-
replaceText?: string;
|
|
34
|
-
setFindTyped: (value: boolean) => void;
|
|
35
|
-
};
|
|
36
|
-
declare const _default: React.FC<import("react-intl-next").WithIntlProps<ReplaceProps & WrappedComponentProps>> & {
|
|
37
|
-
WrappedComponent: React.ComponentType<ReplaceProps & WrappedComponentProps>;
|
|
38
|
-
};
|
|
39
|
-
export default _default;
|